hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
yac_gate_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_YAC_GATE_IMPL_HPP
7 #define IROHA_YAC_GATE_IMPL_HPP
8 
10 
11 #include <memory>
12 
13 #include <rxcpp/rx-lite.hpp>
18 #include "logger/logger_fwd.hpp"
19 
20 namespace iroha {
21 
22  namespace simulator {
23  class BlockCreator;
24  }
25 
26  namespace network {
27  class BlockLoader;
28  }
29 
30  namespace consensus {
31  namespace yac {
32 
33  struct CommitMessage;
34  class YacPeerOrderer;
35 
36  class YacGateImpl : public YacGate {
37  public:
39  std::shared_ptr<HashGate> hash_gate,
40  std::shared_ptr<YacPeerOrderer> orderer,
41  boost::optional<ClusterOrdering> alternative_order,
42  std::shared_ptr<const LedgerState> ledger_state,
43  std::shared_ptr<YacHashProvider> hash_provider,
44  std::shared_ptr<simulator::BlockCreator> block_creator,
45  std::shared_ptr<consensus::ConsensusResultCache>
46  consensus_result_cache,
48  std::function<std::chrono::milliseconds(ConsensusOutcomeType)>
49  delay_func =
50  ConsensusOutcomeDelay(std::chrono::milliseconds(0)));
51  void vote(const simulator::BlockCreatorEvent &event) override;
52 
53  rxcpp::observable<GateObject> onOutcome() override;
54 
55  void stop() override;
56 
57  private:
62  void copySignatures(const CommitMessage &commit);
63 
64  rxcpp::observable<GateObject> handleCommit(const CommitMessage &msg);
65  rxcpp::observable<GateObject> handleReject(const RejectMessage &msg);
66  rxcpp::observable<GateObject> handleFuture(const FutureMessage &msg);
67 
68  logger::LoggerPtr log_;
69 
70  boost::optional<std::shared_ptr<shared_model::interface::Block>>
71  current_block_;
72  YacHash current_hash_;
73  boost::optional<ClusterOrdering> alternative_order_;
74  std::shared_ptr<const LedgerState> current_ledger_state_;
75 
76  rxcpp::observable<GateObject> published_events_;
77  std::shared_ptr<YacPeerOrderer> orderer_;
78  std::shared_ptr<YacHashProvider> hash_provider_;
79  std::shared_ptr<simulator::BlockCreator> block_creator_;
80  std::shared_ptr<consensus::ConsensusResultCache>
81  consensus_result_cache_;
82  std::shared_ptr<HashGate> hash_gate_;
83  };
84 
85  } // namespace yac
86  } // namespace consensus
87 } // namespace iroha
88 
89 #endif // IROHA_YAC_GATE_IMPL_HPP
Definition: block_creator_common.hpp:34
Definition: yac_hash_provider.hpp:30
ConsensusOutcomeType
Definition: consensus_outcome_type.hpp:12
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_loader.hpp:20
Definition: block_query.hpp:15
Definition: consensus_outcome_delay.hpp:16
Definition: yac_gate.hpp:21
Definition: outcome_messages.hpp:73
Definition: outcome_messages.hpp:61
Definition: block_creator.hpp:22
Definition: outcome_messages.hpp:49
Definition: yac_gate_impl.hpp:36