hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
yac_block_storage.hpp
Go to the documentation of this file.
1 
18 #ifndef IROHA_YAC_BLOCK_VOTE_STORAGE_HPP
19 #define IROHA_YAC_BLOCK_VOTE_STORAGE_HPP
20 
21 #include <memory>
22 #include <vector>
23 
24 #include <boost/optional.hpp>
29 #include "logger/logger.hpp"
30 
31 namespace iroha {
32  namespace consensus {
33  namespace yac {
38  private:
39  // --------| fields |--------
40 
44  std::vector<VoteMessage> votes_;
45 
46  public:
48  YacHash hash,
49  PeersNumberType peers_in_round,
50  std::shared_ptr<SupermajorityChecker> supermajority_checker =
51  std::make_shared<SupermajorityCheckerImpl>());
52 
59  boost::optional<Answer> insert(VoteMessage msg);
60 
67  boost::optional<Answer> insert(std::vector<VoteMessage> votes);
68 
72  std::vector<VoteMessage> getVotes() const;
73 
77  size_t getNumberOfVotes() const;
78 
82  boost::optional<Answer> getState();
83 
89  bool isContains(const VoteMessage &msg) const;
90 
94  YacHash getStorageKey() const;
95 
96  private:
97  // --------| private api |--------
98 
104  bool uniqueVote(VoteMessage &vote);
105 
111  bool validScheme(VoteMessage &vote);
112 
113  // --------| fields |--------
114 
118  YacHash storage_key_;
119 
123  PeersNumberType peers_in_round_;
124 
128  std::shared_ptr<SupermajorityChecker> supermajority_checker_;
129 
133  logger::Logger log_;
134  };
135 
136  } // namespace yac
137  } // namespace consensus
138 } // namespace iroha
139 #endif // IROHA_YAC_BLOCK_VOTE_STORAGE_HPP
size_t getNumberOfVotes() const
Definition: yac_block_storage.cpp:54
Definition: yac_hash_provider.hpp:30
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
YacHash getStorageKey() const
Definition: yac_block_storage.cpp:71
Definition: block_query.hpp:16
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
YacBlockStorage(YacHash hash, PeersNumberType peers_in_round, std::shared_ptr< SupermajorityChecker > supermajority_checker=std::make_shared< SupermajorityCheckerImpl >())
Definition: yac_block_storage.cpp:16
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:37