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::consensus::yac {
51  enum class ProposalState {
55  };
56 
61  private:
62  // --------| private api |--------
63 
69  auto getProposalStorage(const Round &round);
70  auto getProposalStorage(const Round &round) const;
71 
80  boost::optional<std::vector<YacProposalStorage>::iterator>
81  findProposalStorage(const VoteMessage &msg, PeersNumberType peers_in_round);
82 
83  public:
84  // --------| public api |--------
85 
91  YacVoteStorage(std::shared_ptr<CleanupStrategy> cleanup_strategy,
92  std::unique_ptr<SupermajorityChecker> supermajority_checker,
93  logger::LoggerManagerTreePtr log_manager);
94 
102  boost::optional<Answer> store(std::vector<VoteMessage> state,
103  PeersNumberType peers_in_round);
104 
110  bool isCommitted(const Round &round);
111 
115  void remove(const Round &round);
116 
123  ProposalState getProcessingState(const Round &round);
124 
133  void nextProcessingState(const Round &round);
134 
139  boost::optional<Round> getLastFinalizedRound() const;
140 
146  boost::optional<Answer> getState(const Round &round) const;
147 
148  private:
149  // --------| fields |--------
150 
151  // TODO: 2019-02-28 @muratovv refactor proposal_storages_ &
152  // processing_state_ with separate entity IR-360
153 
157  std::vector<YacProposalStorage> proposal_storages_;
158 
164  std::unordered_map<Round, ProposalState> processing_state_;
165 
170  std::shared_ptr<CleanupStrategy> strategy_;
171 
173  boost::optional<Round> last_round_;
174 
175  std::shared_ptr<SupermajorityChecker> supermajority_checker_;
176 
177  logger::LoggerManagerTreePtr log_manager_;
178  };
179 } // namespace iroha::consensus::yac
180 
181 #endif // IROHA_YAC_VOTE_STORAGE_HPP
Definition: yac_vote_storage.hpp:60
ProposalState
Definition: yac_vote_storage.hpp:51
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:13
Definition: vote_message.hpp:20
Definition: round.hpp:31
Definition: cluster_order.hpp:16