hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
batch_meta.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_PROTO_BATCH_META_HPP
7 #define IROHA_PROTO_BATCH_META_HPP
8 
10 
11 #include <boost/range/numeric.hpp>
12 #include "cryptography/hash.hpp"
14 #include "transaction.pb.h"
15 
16 namespace shared_model {
17  namespace proto {
18  class BatchMeta final : public interface::BatchMeta {
19  public:
20  explicit BatchMeta(
21  iroha::protocol::Transaction::Payload::BatchMeta &batch_meta)
22  : batch_meta_{batch_meta},
23  type_{[this] {
24  unsigned which = batch_meta_.GetDescriptor()
25  ->FindFieldByName("type")
26  ->enum_type()
27  ->FindValueByNumber(batch_meta_.type())
28  ->index();
29  return static_cast<interface::types::BatchType>(which);
30  }()},
31  reduced_hashes_{boost::accumulate(
32  batch_meta_.reduced_hashes(),
34  [](auto &&acc, const auto &hash) {
35  acc.emplace_back(crypto::Hash::fromHexString(hash));
36  return std::forward<decltype(acc)>(acc);
37  })} {}
38 
39  interface::types::BatchType type() const override {
40  return type_;
41  }
42 
43  const ReducedHashesType &reducedHashes() const override {
44  return reduced_hashes_;
45  }
46 
47  private:
48  const iroha::protocol::Transaction::Payload::BatchMeta &batch_meta_;
49 
51 
52  const ReducedHashesType reduced_hashes_;
53  };
54  } // namespace proto
55 } // namespace shared_model
56 #endif // IROHA_PROTO_BATCH_META_HPP
const ReducedHashesType & reducedHashes() const override
Definition: batch_meta.hpp:43
BatchMeta(iroha::protocol::Transaction::Payload::BatchMeta &batch_meta)
Definition: batch_meta.hpp:20
interface::types::BatchType type() const override
Definition: batch_meta.hpp:39
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
std::vector< interface::types::HashType > ReducedHashesType
type of hashes collection
Definition: batch_meta.hpp:32
Definition: batch_meta.hpp:18
BatchType
Definition: types.hpp:94
Definition: command_executor.hpp:12
Definition: batch_meta.hpp:18
static Hash fromHexString(const std::string &hex)
Definition: hash.cpp:20