hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
on_demand_ordering_init.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_ON_DEMAND_ORDERING_INIT_HPP
7 #define IROHA_ON_DEMAND_ORDERING_INIT_HPP
8 
9 #include <chrono>
10 #include <vector>
11 
12 #include "cryptography/hash.hpp"
14 #include "logger/logger_fwd.hpp"
18 
19 namespace grpc {
20  class Service;
21 }
22 
23 namespace shared_model {
24  namespace interface {
25  class Proposal;
26  class Transaction;
27  class Block;
28  template <typename Interface, typename Transport>
29  class AbstractTransportFactory;
30  class UnsafeProposalFactory;
31  class TransactionBatchParser;
32  class TransactionBatchFactory;
33  } // namespace interface
34 } // namespace shared_model
35 
36 namespace iroha {
37  namespace network {
38  class GenericClientFactory;
39  struct OrderingEvent;
40  class OrderingGate;
41  } // namespace network
42  namespace protocol {
43  class Proposal;
44  class Transaction;
45  } // namespace protocol
46  namespace ametsuchi {
47  class TxPresenceCache;
48  }
49  namespace synchronizer {
50  struct SynchronizationEvent;
51  }
52 } // namespace iroha
53 
54 namespace iroha::ordering {
55  class OnDemandConnectionManager;
56  class OnDemandOrderingGate;
57  class OnDemandOrderingService;
58  class ProposalCreationStrategy;
59  struct ProposalEvent;
60  namespace transport {
61  class OdOsNotification;
62  }
63 
68  public:
69  using TransportFactoryType =
72  iroha::protocol::Proposal>;
73 
74  private:
80  auto createConnectionManager(
81  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
82  std::chrono::milliseconds delay,
83  const logger::LoggerManagerTreePtr &ordering_log_manager,
84  std::shared_ptr<iroha::network::GenericClientFactory> client_factory);
85 
90  auto createGate(
91  std::shared_ptr<OnDemandOrderingService> ordering_service,
92  std::shared_ptr<transport::OdOsNotification> network_client,
93  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
94  proposal_factory,
95  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
96  size_t max_number_of_transactions,
97  const logger::LoggerManagerTreePtr &ordering_log_manager);
98 
103  auto createService(
104  size_t max_number_of_transactions,
105  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
106  proposal_factory,
107  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
108  const logger::LoggerManagerTreePtr &ordering_log_manager);
109 
110  public:
114 
132  std::shared_ptr<network::OrderingGate> initOrderingGate(
133  size_t max_number_of_transactions,
134  std::chrono::milliseconds delay,
137  iroha::protocol::Transaction>> transaction_factory,
138  std::shared_ptr<shared_model::interface::TransactionBatchParser>
139  batch_parser,
140  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
141  transaction_batch_factory,
142  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
143  proposal_factory,
144  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
145  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
146  logger::LoggerManagerTreePtr ordering_log_manager,
147  std::shared_ptr<iroha::network::GenericClientFactory> client_factory,
148  std::chrono::milliseconds proposal_creation_timeout);
149 
150  iroha::ordering::RoundSwitch processSynchronizationEvent(
152 
153  void processRoundSwitch(iroha::ordering::RoundSwitch const &event);
154 
155  void processCommittedBlock(
156  std::shared_ptr<shared_model::interface::Block const> block);
157 
158  void subscribe(
159  std::function<void(network::OrderingEvent const &)> callback);
160 
162  std::shared_ptr<grpc::Service> service;
163 
164  private:
165  shared_model::crypto::Hash previous_hash_, current_hash_;
166  logger::LoggerPtr log_;
167  std::shared_ptr<OnDemandOrderingService> ordering_service_;
168  std::shared_ptr<OnDemandConnectionManager> connection_manager_;
169  std::shared_ptr<OnDemandOrderingGate> ordering_gate_;
170  std::shared_ptr<BaseSubscriber<bool, ProposalEvent>>
171  proposals_subscription_;
172  };
173 } // namespace iroha::ordering
174 
175 #endif // IROHA_ON_DEMAND_ORDERING_INIT_HPP
Definition: application.hpp:65
Definition: round_switch.hpp:18
Definition: block_query.hpp:17
Definition: hash.hpp:18
Definition: on_demand_ordering_init.hpp:67
Definition: proposal.hpp:17
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:15
Definition: ordering_gate_common.hpp:27
Definition: on_demand_ordering_init.hpp:19
Definition: on_demand_os_transport.hpp:32
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
std::shared_ptr< grpc::Service > service
gRPC service for ordering service
Definition: on_demand_ordering_init.hpp:162
Definition: synchronizer_common.hpp:31
Definition: command_executor.hpp:13
Definition: transaction.hpp:23