hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
yac_hash_provider.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_YAC_HASH_PROVIDER_HPP
7 #define IROHA_YAC_HASH_PROVIDER_HPP
8 
9 #include <ciso646>
10 #include <memory>
11 #include <string>
12 
13 #include "consensus/round.hpp"
17 #include "utils/string_builder.hpp"
18 
19 namespace shared_model {
20  namespace interface {
21  class Signature;
22  class Block;
23  } // namespace interface
24 } // namespace shared_model
25 
26 namespace iroha {
27  namespace consensus {
28  namespace yac {
29 
30  class YacHash {
31  public:
32  YacHash(Round round, ProposalHash proposal, BlockHash block)
33  : vote_round{round},
34  vote_hashes{std::move(proposal), std::move(block)} {}
35 
36  YacHash() = default;
37 
42 
46  struct VoteHashes {
51 
56 
59  .init("VoteHashes")
60  .append("proposal", proposal_hash)
61  .append("block", block_hash)
62  .finalize();
63  }
64  };
66 
70  std::shared_ptr<shared_model::interface::Signature> block_signature;
71 
72  bool operator==(const YacHash &obj) const {
73  return vote_round == obj.vote_round
74  and vote_hashes.proposal_hash == obj.vote_hashes.proposal_hash
75  and vote_hashes.block_hash == obj.vote_hashes.block_hash;
76  };
77 
78  bool operator!=(const YacHash &obj) const {
79  return not(*this == obj);
80  };
81 
84  .init("YacHash")
85  .append("round", vote_round.toString())
86  .append("hashes", vote_hashes.toString())
87  .finalize();
88  }
89  };
90 
95  public:
99  virtual YacHash makeHash(
100  const simulator::BlockCreatorEvent &event) const = 0;
101 
107  virtual shared_model::interface::types::HashType toModelHash(
108  const YacHash &hash) const = 0;
109 
110  virtual ~YacHashProvider() = default;
111  };
112  } // namespace yac
113  } // namespace consensus
114 } // namespace iroha
115 
116 #endif // IROHA_YAC_HASH_PROVIDER_HPP
Definition: block_creator_common.hpp:33
Definition: hash.hpp:18
PrettyStringBuilder & init(const std::string &name)
Definition: string_builder.cpp:18
std::shared_ptr< shared_model::interface::Signature > block_signature
Definition: yac_hash_provider.hpp:70
YacHash(Round round, ProposalHash proposal, BlockHash block)
Definition: yac_hash_provider.hpp:32
Definition: yac_hash_provider.hpp:30
std::string finalize()
Definition: string_builder.cpp:52
std::string ProposalHash
Definition: yac_common.hpp:22
string(REPLACE".""/"CMAKE_SWIG_OUTDIR ${SWIG_JAVA_PKG}) else() set(CMAKE_SWIG_FLAGS"") endif() myswig_add_library(irohajava LANGUAGE java SOURCES bindings.i) unset(CMAKE_SWIG_FLAGS) swig_link_libraries(irohajava $
Definition: CMakeLists.txt:54
std::string toString() const
Definition: yac_hash_provider.hpp:57
Definition: string_builder.hpp:16
Definition: block_query.hpp:16
Definition: yac_hash_provider.hpp:94
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
bool operator!=(const YacHash &obj) const
Definition: yac_hash_provider.hpp:78
std::string toString() const
Definition: yac_hash_provider.hpp:82
PrettyStringBuilder & append(const std::string &name, const std::string &value)
Definition: string_builder.cpp:36
std::string toString() const
Definition: round.cpp:41
Definition: yac_hash_provider.hpp:46
ProposalHash proposal_hash
Definition: yac_hash_provider.hpp:50
VoteHashes vote_hashes
Definition: yac_hash_provider.hpp:65
BlockHash block_hash
Definition: yac_hash_provider.hpp:55
Definition: round.hpp:31
std::string BlockHash
Definition: yac_common.hpp:24
Definition: command_executor.hpp:12
bool operator==(const YacHash &obj) const
Definition: yac_hash_provider.hpp:72
Round vote_round
Definition: yac_hash_provider.hpp:41