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/adaptor/transformed.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::copy_range<ReducedHashesType>(
32  batch_meta.reduced_hashes()
33  | boost::adaptors::transformed([](const auto &hash) {
35  }))} {}
36 
37  interface::types::BatchType type() const override {
38  return type_;
39  }
40 
41  const ReducedHashesType &reducedHashes() const override {
42  return reduced_hashes_;
43  }
44 
45  private:
46  const iroha::protocol::Transaction::Payload::BatchMeta &batch_meta_;
47 
49 
50  const ReducedHashesType reduced_hashes_;
51  };
52  } // namespace proto
53 } // namespace shared_model
54 #endif // IROHA_PROTO_BATCH_META_HPP
const ReducedHashesType & reducedHashes() const override
Definition: batch_meta.hpp:41
BatchMeta(iroha::protocol::Transaction::Payload::BatchMeta &batch_meta)
Definition: batch_meta.hpp:20
interface::types::BatchType type() const override
Definition: batch_meta.hpp:37
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