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<YacHashProvider> hash_provider,
43  std::shared_ptr<simulator::BlockCreator> block_creator,
44  std::shared_ptr<consensus::ConsensusResultCache>
45  consensus_result_cache,
47  std::function<std::chrono::milliseconds(ConsensusOutcomeType)>
48  delay_func =
49  ConsensusOutcomeDelay(std::chrono::milliseconds(0)));
50  void vote(const simulator::BlockCreatorEvent &event) override;
51 
52  rxcpp::observable<GateObject> onOutcome() override;
53 
54  void stop() override;
55 
56  private:
61  void copySignatures(const CommitMessage &commit);
62 
63  rxcpp::observable<GateObject> handleCommit(const CommitMessage &msg);
64  rxcpp::observable<GateObject> handleReject(const RejectMessage &msg);
65  rxcpp::observable<GateObject> handleFuture(const FutureMessage &msg);
66 
67  logger::LoggerPtr log_;
68 
69  boost::optional<std::shared_ptr<shared_model::interface::Block>>
70  current_block_;
71  YacHash current_hash_;
72  boost::optional<ClusterOrdering> alternative_order_;
73  std::shared_ptr<const LedgerState> current_ledger_state_;
74 
75  rxcpp::observable<GateObject> published_events_;
76  std::shared_ptr<YacPeerOrderer> orderer_;
77  std::shared_ptr<YacHashProvider> hash_provider_;
78  std::shared_ptr<simulator::BlockCreator> block_creator_;
79  std::shared_ptr<consensus::ConsensusResultCache>
80  consensus_result_cache_;
81  std::shared_ptr<HashGate> hash_gate_;
82  };
83 
84  } // namespace yac
85  } // namespace consensus
86 } // namespace iroha
87 
88 #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