hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
yac_block_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_YAC_BLOCK_VOTE_STORAGE_HPP
7 #define IROHA_YAC_BLOCK_VOTE_STORAGE_HPP
8 
9 #include <memory>
10 #include <vector>
11 
12 #include <boost/optional.hpp>
17 #include "logger/logger_fwd.hpp"
18 
19 namespace iroha {
20  namespace consensus {
21  namespace yac {
26  private:
27  // --------| fields |--------
28 
32  std::vector<VoteMessage> votes_;
33 
34  public:
36  YacHash hash,
37  PeersNumberType peers_in_round,
38  std::shared_ptr<SupermajorityChecker> supermajority_checker,
39  logger::LoggerPtr log);
40 
47  boost::optional<Answer> insert(VoteMessage msg);
48 
55  boost::optional<Answer> insert(std::vector<VoteMessage> votes);
56 
60  std::vector<VoteMessage> getVotes() const;
61 
65  size_t getNumberOfVotes() const;
66 
70  boost::optional<Answer> getState();
71 
77  bool isContains(const VoteMessage &msg) const;
78 
82  YacHash getStorageKey() const;
83 
84  private:
85  // --------| private api |--------
86 
92  bool uniqueVote(VoteMessage &vote);
93 
99  bool validScheme(VoteMessage &vote);
100 
101  // --------| fields |--------
102 
106  YacHash storage_key_;
107 
111  PeersNumberType peers_in_round_;
112 
116  std::shared_ptr<SupermajorityChecker> supermajority_checker_;
117 
121  logger::LoggerPtr log_;
122  };
123 
124  } // namespace yac
125  } // namespace consensus
126 } // namespace iroha
127 #endif // IROHA_YAC_BLOCK_VOTE_STORAGE_HPP
size_t getNumberOfVotes() const
Definition: yac_block_storage.cpp:54
YacBlockStorage(YacHash hash, PeersNumberType peers_in_round, std::shared_ptr< SupermajorityChecker > supermajority_checker, logger::LoggerPtr log)
Definition: yac_block_storage.cpp:16
Definition: yac_hash_provider.hpp:30
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
YacHash getStorageKey() const
Definition: yac_block_storage.cpp:71
Definition: block_query.hpp:14
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
boost::optional< Answer > getState()
Definition: yac_block_storage.cpp:58
size_t PeersNumberType
Type for number of peers in round.
Definition: yac_types.hpp:16
std::vector< VoteMessage > getVotes() const
Definition: yac_block_storage.cpp:50
Definition: vote_message.hpp:22
boost::optional< Answer > insert(VoteMessage msg)
Definition: yac_block_storage.cpp:26
bool isContains(const VoteMessage &msg) const
Definition: yac_block_storage.cpp:67
Definition: yac_block_storage.hpp:25