hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
vote_message.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_VOTE_MESSAGE_HPP
7 #define IROHA_VOTE_MESSAGE_HPP
8 
9 #include <memory>
10 
11 #include <boost/functional/hash.hpp>
12 #include "consensus/yac/yac_hash_provider.hpp" // for YacHash
14 #include "utils/string_builder.hpp"
15 
16 namespace iroha::consensus::yac {
20  struct VoteMessage {
22  std::shared_ptr<shared_model::interface::Signature> signature;
23 
24  bool operator==(const VoteMessage &rhs) const {
25  return hash == rhs.hash and *signature == *rhs.signature;
26  }
27 
28  bool operator!=(const VoteMessage &rhs) const {
29  return not(*this == rhs);
30  }
31 
32  std::string toString() const {
34  .init("VoteMessage")
35  .appendNamed("yac hash", hash)
36  .appendNamed("signature", signature)
37  .finalize();
38  }
39  };
40 } // namespace iroha::consensus::yac
41 
42 namespace std {
43  template <>
44  struct hash<iroha::consensus::yac::VoteMessage> {
45  std::size_t operator()(iroha::consensus::yac::VoteMessage const &m) const
46  noexcept {
47  std::size_t seed = 0;
48  boost::hash_combine(seed, m.signature->publicKey());
49  boost::hash_combine(seed, m.hash.vote_round);
50  boost::hash_combine(seed, m.hash.vote_hashes.proposal_hash);
51  boost::hash_combine(seed, m.hash.vote_hashes.block_hash);
52  return seed;
53  }
54  };
55 } // namespace std
56 
57 #endif // IROHA_VOTE_MESSAGE_HPP
std::string toString() const
Definition: vote_message.hpp:32
PrettyStringBuilder & init(const std::string &name)
Definition: string_builder.cpp:18
Definition: yac_hash_provider.hpp:25
std::string finalize()
Definition: string_builder.cpp:44
Definition: round.cpp:51
std::shared_ptr< shared_model::interface::Signature > signature
Definition: vote_message.hpp:22
Definition: string_builder.hpp:18
Definition: block_query.hpp:15
std::size_t operator()(iroha::consensus::yac::VoteMessage const &m) const noexcept
Definition: vote_message.hpp:45
YacHash hash
Definition: vote_message.hpp:21
bool operator==(const VoteMessage &rhs) const
Definition: vote_message.hpp:24
Definition: vote_message.hpp:20
bool operator!=(const VoteMessage &rhs) const
Definition: vote_message.hpp:28
PrettyStringBuilder & appendNamed(const Name &name, const Value &value)
----—— Augmented appending functions. ----—— ///
Definition: string_builder.hpp:53
Definition: cluster_order.hpp:16