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::consensus::yac {
15  template <typename>
16  struct OutcomeMessage {
17  explicit OutcomeMessage(std::vector<VoteMessage> votes)
18  : votes(std::move(votes)) {}
19 
20  OutcomeMessage(std::initializer_list<VoteMessage> votes) : votes(votes) {}
21 
22  std::vector<VoteMessage> votes;
23 
24  bool operator==(const OutcomeMessage &rhs) const {
25  return votes == rhs.votes;
26  }
27 
28  std::string toString() const {
30  .init(typeName())
31  .appendNamed("votes", votes)
32  .finalize();
33  }
34 
35  virtual const std::string &typeName() const = 0;
36 
37  protected:
38  ~OutcomeMessage() = default;
39  };
40 
45  struct CommitMessage final : OutcomeMessage<CommitMessage> {
47  const std::string &typeName() const override {
48  const static std::string name{"CommitMessage"};
49  return name;
50  }
51  };
52 
57  struct RejectMessage final : OutcomeMessage<RejectMessage> {
59  const std::string &typeName() const override {
60  const static std::string name{"RejectMessage"};
61  return name;
62  }
63  };
64 
69  struct FutureMessage final : OutcomeMessage<FutureMessage> {
71  const std::string &typeName() const override {
72  const static std::string name{"FutureMessage"};
73  return name;
74  }
75  };
76 } // namespace iroha::consensus::yac
77 
78 #endif // IROHA_MESSAGES_HPP
const std::string & typeName() const override
Definition: outcome_messages.hpp:71
PrettyStringBuilder & init(const std::string &name)
Definition: string_builder.cpp:18
Definition: outcome_messages.hpp:16
const std::string & typeName() const override
Definition: outcome_messages.hpp:59
std::string finalize()
Definition: string_builder.cpp:44
OutcomeMessage(std::initializer_list< VoteMessage > votes)
Definition: outcome_messages.hpp:20
Definition: round.cpp:51
virtual const std::string & typeName() const =0
Definition: string_builder.hpp:18
bool operator==(const OutcomeMessage &rhs) const
Definition: outcome_messages.hpp:24
const std::string & typeName() const override
Definition: outcome_messages.hpp:47
Definition: outcome_messages.hpp:69
Definition: outcome_messages.hpp:57
std::vector< VoteMessage > votes
Definition: outcome_messages.hpp:22
OutcomeMessage(std::vector< VoteMessage > votes)
Definition: outcome_messages.hpp:17
std::string toString() const
Definition: outcome_messages.hpp:28
PrettyStringBuilder & appendNamed(const Name &name, const Value &value)
----—— Augmented appending functions. ----—— ///
Definition: string_builder.hpp:53
Definition: outcome_messages.hpp:45
Definition: cluster_order.hpp:16