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::consensus::yac {
24  private:
25  // --------| fields |--------
26 
30  std::vector<VoteMessage> votes_;
31 
32  public:
34  PeersNumberType peers_in_round,
35  std::shared_ptr<SupermajorityChecker> supermajority_checker,
36  logger::LoggerPtr log);
37 
44  boost::optional<Answer> insert(VoteMessage msg);
45 
52  boost::optional<Answer> insert(std::vector<VoteMessage> votes);
53 
57  std::vector<VoteMessage> getVotes() const;
58 
62  size_t getNumberOfVotes() const;
63 
67  boost::optional<Answer> getState();
68 
74  bool isContains(const VoteMessage &msg) const;
75 
79  YacHash getStorageKey() const;
80 
81  private:
82  // --------| private api |--------
83 
89  bool uniqueVote(VoteMessage &vote);
90 
96  bool validScheme(VoteMessage &vote);
97 
98  // --------| fields |--------
99 
103  YacHash storage_key_;
104 
108  PeersNumberType peers_in_round_;
109 
113  std::shared_ptr<SupermajorityChecker> supermajority_checker_;
114 
118  logger::LoggerPtr log_;
119  };
120 } // namespace iroha::consensus::yac
121 
122 #endif // IROHA_YAC_BLOCK_VOTE_STORAGE_HPP
Definition: yac_hash_provider.hpp:25
boost::optional< Answer > insert(VoteMessage msg)
Definition: yac_block_storage.cpp:24
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
std::vector< VoteMessage > getVotes() const
Definition: yac_block_storage.cpp:49
boost::optional< Answer > getState()
Definition: yac_block_storage.cpp:58
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
YacBlockStorage(YacHash hash, PeersNumberType peers_in_round, std::shared_ptr< SupermajorityChecker > supermajority_checker, logger::LoggerPtr log)
Definition: yac_block_storage.cpp:14
size_t getNumberOfVotes() const
Definition: yac_block_storage.cpp:54
size_t PeersNumberType
Type for number of peers in round.
Definition: yac_types.hpp:13
YacHash getStorageKey() const
Definition: yac_block_storage.cpp:71
Definition: vote_message.hpp:20
bool isContains(const VoteMessage &msg) const
Definition: yac_block_storage.cpp:67
Definition: yac_block_storage.hpp:23
Definition: cluster_order.hpp:16