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 
18  template <typename>
19  struct OutcomeMessage {
20  explicit OutcomeMessage(std::vector<VoteMessage> votes)
21  : votes(std::move(votes)) {}
22 
23  OutcomeMessage(std::initializer_list<VoteMessage> votes)
24  : votes(votes) {}
25 
26  std::vector<VoteMessage> votes;
27 
28  bool operator==(const OutcomeMessage &rhs) const {
29  return votes == rhs.votes;
30  }
31 
32  std::string toString() const {
34  .init(typeName())
35  .appendNamed("votes", votes)
36  .finalize();
37  }
38 
39  virtual const std::string &typeName() const = 0;
40 
41  protected:
42  ~OutcomeMessage() = default;
43  };
44 
49  struct CommitMessage final : OutcomeMessage<CommitMessage> {
51  const std::string &typeName() const override {
52  const static std::string name{"CommitMessage"};
53  return name;
54  }
55  };
56 
61  struct RejectMessage final : OutcomeMessage<RejectMessage> {
63  const std::string &typeName() const override {
64  const static std::string name{"RejectMessage"};
65  return name;
66  }
67  };
68 
73  struct FutureMessage final : OutcomeMessage<FutureMessage> {
75  const std::string &typeName() const override {
76  const static std::string name{"FutureMessage"};
77  return name;
78  }
79  };
80  } // namespace yac
81  } // namespace consensus
82 } // namespace iroha
83 #endif // IROHA_MESSAGES_HPP
const std::string & typeName() const override
Definition: outcome_messages.hpp:75
PrettyStringBuilder & init(const std::string &name)
Definition: string_builder.cpp:18
Definition: outcome_messages.hpp:19
const std::string & typeName() const override
Definition: outcome_messages.hpp:63
std::string finalize()
Definition: string_builder.cpp:44
OutcomeMessage(std::initializer_list< VoteMessage > votes)
Definition: outcome_messages.hpp:23
Definition: peer.hpp:48
virtual const std::string & typeName() const =0
Definition: string_builder.hpp:18
Definition: block_query.hpp:15
bool operator==(const OutcomeMessage &rhs) const
Definition: outcome_messages.hpp:28
const std::string & typeName() const override
Definition: outcome_messages.hpp:51
Definition: outcome_messages.hpp:73
Definition: outcome_messages.hpp:61
std::vector< VoteMessage > votes
Definition: outcome_messages.hpp:26
OutcomeMessage(std::vector< VoteMessage > votes)
Definition: outcome_messages.hpp:20
std::string toString() const
Definition: outcome_messages.hpp:32
PrettyStringBuilder & appendNamed(const Name &name, const Value &value)
----—— Augmented appending functions. ----—— ///
Definition: string_builder.hpp:53
Definition: outcome_messages.hpp:49