hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
yac_vote_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_YAC_VOTE_STORAGE_HPP
7 #define IROHA_YAC_VOTE_STORAGE_HPP
8 
9 #include <memory>
10 #include <unordered_map>
11 #include <vector>
12 
13 #include <boost/optional.hpp>
15 #include "consensus/yac/outcome_messages.hpp" // because messages passed by value
17 #include "consensus/yac/storage/storage_result.hpp" // for Answer
18 #include "consensus/yac/storage/yac_common.hpp" // for ProposalHash
23 
24 namespace iroha {
25  namespace consensus {
26  namespace yac {
27 
54  enum class ProposalState {
58  };
59 
64  private:
65  // --------| private api |--------
66 
72  auto getProposalStorage(const Round &round);
73  auto getProposalStorage(const Round &round) const;
74 
83  boost::optional<std::vector<YacProposalStorage>::iterator>
84  findProposalStorage(const VoteMessage &msg,
85  PeersNumberType peers_in_round);
86 
90  void remove(const Round &round);
91 
92  public:
93  // --------| public api |--------
94 
101  std::shared_ptr<CleanupStrategy> cleanup_strategy,
102  std::unique_ptr<SupermajorityChecker> supermajority_checker,
103  logger::LoggerManagerTreePtr log_manager);
104 
112  boost::optional<Answer> store(std::vector<VoteMessage> state,
113  PeersNumberType peers_in_round);
114 
120  bool isCommitted(const Round &round);
121 
128  ProposalState getProcessingState(const Round &round);
129 
138  void nextProcessingState(const Round &round);
139 
144  boost::optional<Round> getLastFinalizedRound() const;
145 
151  boost::optional<Answer> getState(const Round &round) const;
152 
153  private:
154  // --------| fields |--------
155 
156  // TODO: 2019-02-28 @muratovv refactor proposal_storages_ &
157  // processing_state_ with separate entity IR-360
158 
162  std::vector<YacProposalStorage> proposal_storages_;
163 
169  std::unordered_map<Round, ProposalState, RoundTypeHasher>
170  processing_state_;
171 
176  std::shared_ptr<CleanupStrategy> strategy_;
177 
179  boost::optional<Round> last_round_;
180 
181  std::shared_ptr<SupermajorityChecker> supermajority_checker_;
182 
183  logger::LoggerManagerTreePtr log_manager_;
184  };
185 
186  } // namespace yac
187  } // namespace consensus
188 } // namespace iroha
189 
190 #endif // IROHA_YAC_VOTE_STORAGE_HPP
Definition: yac_vote_storage.hpp:63
ProposalState
Definition: yac_vote_storage.hpp:54
Definition: block_query.hpp:14
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
size_t PeersNumberType
Type for number of peers in round.
Definition: yac_types.hpp:16
Definition: vote_message.hpp:22
Definition: round.hpp:31