hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
yac_proposal_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_YAC_PROPOSAL_STORAGE_HPP
7 #define IROHA_YAC_PROPOSAL_STORAGE_HPP
8 
9 #include <memory>
10 #include <vector>
11 
12 #include <boost/optional.hpp>
18 #include "logger/logger.hpp"
19 
20 namespace iroha {
21  namespace consensus {
22  namespace yac {
23 
24  struct VoteMessage;
25 
31  private:
32  // --------| private api |--------
33 
40  auto findStore(const YacHash &store_hash);
41 
42  public:
43  // --------| public api |--------
44 
46  Round store_round,
47  PeersNumberType peers_in_round,
48  std::shared_ptr<SupermajorityChecker> supermajority_checker =
49  std::make_shared<SupermajorityCheckerImpl>());
50 
58  boost::optional<Answer> insert(VoteMessage vote);
59 
66  boost::optional<Answer> insert(std::vector<VoteMessage> messages);
67 
71  const Round &getStorageKey() const;
72 
76  boost::optional<Answer> getState() const;
77 
78  private:
79  // --------| private api |--------
80 
86  bool shouldInsert(const VoteMessage &msg);
87 
93  bool checkProposalRound(const Round &vote_round);
94 
99  bool checkPeerUniqueness(const VoteMessage &msg);
100 
107  boost::optional<Answer> findRejectProof();
108 
109  // --------| fields |--------
110 
114  boost::optional<Answer> current_state_;
115 
119  std::vector<YacBlockStorage> block_storages_;
120 
124  Round storage_key_;
125 
129  PeersNumberType peers_in_round_;
130 
134  std::shared_ptr<SupermajorityChecker> supermajority_checker_;
135 
139  logger::Logger log_;
140  };
141  } // namespace yac
142  } // namespace consensus
143 } // namespace iroha
144 #endif // IROHA_YAC_PROPOSAL_STORAGE_HPP
boost::optional< Answer > insert(VoteMessage vote)
Definition: yac_proposal_storage.cpp:51
YacProposalStorage(Round store_round, PeersNumberType peers_in_round, std::shared_ptr< SupermajorityChecker > supermajority_checker=std::make_shared< SupermajorityCheckerImpl >())
Definition: yac_proposal_storage.cpp:40
Definition: yac_hash_provider.hpp:30
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block_query.hpp:16
const Round & getStorageKey() const
Definition: yac_proposal_storage.cpp:88
size_t PeersNumberType
Type for number of peers in round.
Definition: yac_types.hpp:16
boost::optional< Answer > getState() const
Definition: yac_proposal_storage.cpp:92
Definition: vote_message.hpp:22
Definition: yac_proposal_storage.hpp:30
Definition: round.hpp:31