hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
outcome_messages.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_MESSAGES_HPP
7 #define IROHA_MESSAGES_HPP
8 
9 #include <vector>
10 
12 #include "utils/string_builder.hpp"
13 
14 namespace iroha {
15  namespace consensus {
16  namespace yac {
17 
22  struct CommitMessage {
23  explicit CommitMessage(std::vector<VoteMessage> votes)
24  : votes(std::move(votes)) {}
25 
26  std::vector<VoteMessage> votes;
27 
28  bool operator==(const CommitMessage &rhs) const {
29  return votes == rhs.votes;
30  }
31 
32  std::string toString() const {
34  .init("CommitMessage")
35  .appendAll(
36  "votes", votes, [](auto vote) { return vote.toString(); })
37  .finalize();
38  }
39  };
40 
45  struct RejectMessage {
46  explicit RejectMessage(std::vector<VoteMessage> votes)
47  : votes(std::move(votes)) {}
48 
49  std::vector<VoteMessage> votes;
50 
51  bool operator==(const RejectMessage &rhs) const {
52  return votes == rhs.votes;
53  }
54 
55  std::string toString() const {
57  .init("RejectMessage")
58  .appendAll(
59  "votes", votes, [](auto vote) { return vote.toString(); })
60  .finalize();
61  }
62  };
63  } // namespace yac
64  } // namespace consensus
65 } // namespace iroha
66 #endif // IROHA_MESSAGES_HPP
std::string toString() const
Definition: outcome_messages.hpp:55
PrettyStringBuilder & init(const std::string &name)
Definition: string_builder.cpp:18
Definition: peer.hpp:48
std::vector< VoteMessage > votes
Definition: outcome_messages.hpp:26
PrettyStringBuilder & appendAll(Collection &&c, Transform &&t)
Definition: string_builder.hpp:56
std::string toString() const
Definition: outcome_messages.hpp:32
Definition: string_builder.hpp:16
bool operator==(const RejectMessage &rhs) const
Definition: outcome_messages.hpp:51
Definition: block_query.hpp:14
RejectMessage(std::vector< VoteMessage > votes)
Definition: outcome_messages.hpp:46
CommitMessage(std::vector< VoteMessage > votes)
Definition: outcome_messages.hpp:23
std::vector< VoteMessage > votes
Definition: outcome_messages.hpp:49
Definition: outcome_messages.hpp:45
bool operator==(const CommitMessage &rhs) const
Definition: outcome_messages.hpp:28
Definition: outcome_messages.hpp:22