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 #include <optional>
13 
19 #include "logger/logger_fwd.hpp"
20 
21 namespace iroha {
22  namespace simulator {
23  class BlockCreator;
24  }
25  namespace network {
26  class BlockLoader;
27  }
28 } // namespace iroha
29 
30 namespace iroha::consensus::yac {
31  struct CommitMessage;
32  class YacPeerOrderer;
33 
34  class YacGateImpl : public YacGate {
35  public:
37  std::shared_ptr<HashGate> hash_gate,
38  std::shared_ptr<YacPeerOrderer> orderer,
39  std::optional<ClusterOrdering> alternative_order,
40  std::shared_ptr<const LedgerState> ledger_state,
41  std::shared_ptr<YacHashProvider> hash_provider,
42  std::shared_ptr<consensus::ConsensusResultCache> consensus_result_cache,
43  logger::LoggerPtr log);
44  void vote(const simulator::BlockCreatorEvent &event) override;
45 
46  std::optional<GateObject> processOutcome(Answer const &outcome);
47 
48  void stop() override;
49 
50  std::optional<GateObject> processRoundSwitch(
51  consensus::Round const &round,
52  std::shared_ptr<LedgerState const> ledger_state);
53 
54  private:
59  void copySignatures(const CommitMessage &commit);
60 
61  std::optional<GateObject> handleCommit(const CommitMessage &msg);
62  std::optional<GateObject> handleReject(const RejectMessage &msg);
63  std::optional<GateObject> handleFuture(const FutureMessage &msg);
64 
65  logger::LoggerPtr log_;
66 
67  std::optional<std::shared_ptr<shared_model::interface::Block>>
68  current_block_;
69  YacHash current_hash_;
70  std::optional<ClusterOrdering> alternative_order_;
71  std::shared_ptr<const LedgerState> current_ledger_state_;
72 
73  std::shared_ptr<YacPeerOrderer> orderer_;
74  std::shared_ptr<YacHashProvider> hash_provider_;
75  std::shared_ptr<consensus::ConsensusResultCache> consensus_result_cache_;
76  std::shared_ptr<HashGate> hash_gate_;
77  };
78 } // namespace iroha::consensus::yac
79 
80 #endif // IROHA_YAC_GATE_IMPL_HPP
Definition: block_creator_common.hpp:34
Definition: yac_hash_provider.hpp:25
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_loader.hpp:36
Definition: block_query.hpp:15
Definition: yac_gate.hpp:23
Definition: outcome_messages.hpp:69
Definition: outcome_messages.hpp:57
boost::variant< CommitMessage, RejectMessage, FutureMessage > Answer
Definition: storage_result.hpp:19
Definition: round.hpp:31
Definition: block_creator.hpp:18
Definition: outcome_messages.hpp:45
Definition: cluster_order.hpp:16
Definition: yac_gate_impl.hpp:34