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 
13 #include "logger/logger.hpp"
14 #include "network/block_loader.hpp"
17 
18 namespace iroha {
19 
20  namespace ametsuchi {
21  class BlockQueryFactory;
22  }
23 
24  namespace synchronizer {
25 
26  class SynchronizerImpl : public Synchronizer {
27  public:
29  std::shared_ptr<network::ConsensusGate> consensus_gate,
30  std::shared_ptr<validation::ChainValidator> validator,
31  std::shared_ptr<ametsuchi::MutableFactory> mutable_factory,
32  std::shared_ptr<ametsuchi::BlockQueryFactory> block_query_factory,
33  std::shared_ptr<network::BlockLoader> block_loader,
34  logger::Logger log = logger::log("Synchronizer"));
35 
36  ~SynchronizerImpl() override;
37 
38  void processOutcome(consensus::GateObject object) override;
39  rxcpp::observable<SynchronizationEvent> on_commit_chain() override;
40 
41  private:
51  boost::optional<SynchronizationEvent> downloadMissingBlocks(
52  const consensus::VoteOther &msg,
53  std::unique_ptr<ametsuchi::MutableStorage> storage,
55 
56  void processNext(const consensus::PairValid &msg);
57  void processDifferent(const consensus::VoteOther &msg);
58 
59  boost::optional<std::unique_ptr<ametsuchi::MutableStorage>> getStorage();
60 
61  std::shared_ptr<validation::ChainValidator> validator_;
62  std::shared_ptr<ametsuchi::MutableFactory> mutable_factory_;
63  std::shared_ptr<ametsuchi::BlockQueryFactory> block_query_factory_;
64  std::shared_ptr<network::BlockLoader> block_loader_;
65 
66  // internal
67  rxcpp::subjects::subject<SynchronizationEvent> notifier_;
68  rxcpp::composite_subscription subscription_;
69 
70  logger::Logger log_;
71  };
72 
73  } // namespace synchronizer
74 } // namespace iroha
75 
76 #endif // IROHA_SYNCHRONIZER_IMPL_HPP
Current pair is valid.
Definition: gate_object.hpp:25
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:41
Definition: synchronizer_impl.hpp:26
Network votes for another pair and round.
Definition: gate_object.hpp:31
Definition: synchronizer.hpp:19
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block_query.hpp:16
Logger log(const std::string &tag)
Definition: logger.cpp:48
boost::variant< PairValid, VoteOther, ProposalReject, BlockReject, AgreementOnNone > GateObject
Definition: gate_object.hpp:56