hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
consensus_init.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_CONSENSUS_INIT_HPP
7 #define IROHA_CONSENSUS_INIT_HPP
8 
9 #include <memory>
10 
16 #include "consensus/yac/timer.hpp"
21 #include "cryptography/keypair.hpp"
24 #include "network/block_loader.hpp"
25 
26 namespace iroha::network {
27  class GenericClientFactory;
28 }
29 
30 namespace iroha::consensus::yac {
31  class Yac;
32  class YacGateImpl;
33 
34  class YacInit {
35  public:
36  std::shared_ptr<YacGate> initConsensusGate(
37  Round initial_round,
38  std::optional<shared_model::interface::types::PeerList>
39  alternative_peers,
40  std::shared_ptr<const LedgerState> ledger_state,
41  std::shared_ptr<network::BlockLoader> block_loader,
42  const shared_model::crypto::Keypair &keypair,
43  std::shared_ptr<consensus::ConsensusResultCache> block_cache,
44  std::chrono::milliseconds vote_delay_milliseconds,
45  ConsistencyModel consistency_model,
46  const logger::LoggerManagerTreePtr &consensus_log_manager,
47  std::shared_ptr<iroha::network::GenericClientFactory> client_factory);
48 
49  std::shared_ptr<ServiceImpl> getConsensusNetwork() const;
50 
51  void subscribe(std::function<void(GateObject const &)> callback);
52 
53  std::optional<GateObject> processRoundSwitch(
54  consensus::Round const &round,
55  std::shared_ptr<LedgerState const> ledger_state);
56 
57  private:
58  auto createTimer(std::chrono::milliseconds delay_milliseconds);
59 
60  bool initialized_{false};
61  std::shared_ptr<ServiceImpl> consensus_network_;
62  std::shared_ptr<Yac> yac_;
63  std::shared_ptr<YacGateImpl> yac_gate_;
64  std::shared_ptr<BaseSubscriber<bool, std::vector<VoteMessage>>>
65  states_subscription_;
66  };
67 } // namespace iroha::consensus::yac
68 
69 #endif // IROHA_CONSENSUS_INIT_HPP
Definition: yac_gate_impl.hpp:25
Definition: consensus_init.hpp:34
Definition: keypair.hpp:19
std::variant< PairValid, VoteOther, ProposalReject, BlockReject, AgreementOnNone, Future > GateObject
Definition: gate_object.hpp:96
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
ConsistencyModel
Definition: consistency_model.hpp:10
Definition: round.hpp:31
Definition: cluster_order.hpp:16