hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
synchronizer_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SYNCHRONIZER_IMPL_HPP
7 #define IROHA_SYNCHRONIZER_IMPL_HPP
8 
10 
11 #include <rxcpp/rx-lite.hpp>
15 #include "logger/logger_fwd.hpp"
16 #include "network/block_loader.hpp"
19 
20 namespace iroha {
21 
22  namespace ametsuchi {
23  class BlockQueryFactory;
24  class CommandExecutor;
25  } // namespace ametsuchi
26 
27  namespace synchronizer {
28 
29  class SynchronizerImpl : public Synchronizer {
30  public:
32  std::unique_ptr<iroha::ametsuchi::CommandExecutor> command_executor,
33  std::shared_ptr<network::ConsensusGate> consensus_gate,
34  std::shared_ptr<validation::ChainValidator> validator,
35  std::shared_ptr<ametsuchi::MutableFactory> mutable_factory,
36  std::shared_ptr<ametsuchi::BlockQueryFactory> block_query_factory,
37  std::shared_ptr<network::BlockLoader> block_loader,
38  logger::LoggerPtr log);
39 
40  ~SynchronizerImpl() override;
41 
42  void processOutcome(consensus::GateObject object) override;
43  rxcpp::observable<SynchronizationEvent> on_commit_chain() override;
44 
45  private:
46  using PublicKeysRange =
48  boost::forward_traversal_tag,
49  const shared_model::interface::types::PubkeyType &>;
58  ametsuchi::CommitResult downloadAndCommitMissingBlocks(
61  const PublicKeysRange &public_keys);
62 
63  void processNext(const consensus::PairValid &msg);
64 
70  void processDifferent(
71  const consensus::Synchronizable &msg,
73 
74  std::unique_ptr<ametsuchi::MutableStorage> getStorage();
75 
76  std::shared_ptr<iroha::ametsuchi::CommandExecutor> command_executor_;
77 
78  std::shared_ptr<validation::ChainValidator> validator_;
79  std::shared_ptr<ametsuchi::MutableFactory> mutable_factory_;
80  std::shared_ptr<ametsuchi::BlockQueryFactory> block_query_factory_;
81  std::shared_ptr<network::BlockLoader> block_loader_;
82 
83  // internal
84  rxcpp::composite_subscription notifier_lifetime_;
85  rxcpp::subjects::subject<SynchronizationEvent> notifier_;
86  rxcpp::composite_subscription subscription_;
87 
88  logger::LoggerPtr log_;
89  };
90 
91  } // namespace synchronizer
92 } // namespace iroha
93 
94 #endif // IROHA_SYNCHRONIZER_IMPL_HPP
Current pair is valid.
Definition: gate_object.hpp:35
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:43
Definition: synchronizer_impl.hpp:29
Definition: synchronizer.hpp:19
iroha::expected::Result< std::shared_ptr< const iroha::LedgerState >, std::string > CommitResult
Definition: commit_result.hpp:20
Definition: gate_object.hpp:45
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:14
crypto::PublicKey PubkeyType
Type of public key.
Definition: types.hpp:47
boost::variant< PairValid, VoteOther, ProposalReject, BlockReject, AgreementOnNone, Future > GateObject
Definition: gate_object.hpp:96