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 <random>
10 
11 #include "ametsuchi/storage.hpp"
14 #include "logger/logger_fwd.hpp"
19 #include "ordering.grpc.pb.h"
24 
25 namespace iroha {
26  namespace network {
27 
32  public:
33  using TransportFactoryType =
36  iroha::protocol::Proposal>;
37 
38  private:
43  auto createNotificationFactory(
45  async_call,
46  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
47  std::chrono::milliseconds delay,
48  const logger::LoggerManagerTreePtr &ordering_log_manager);
49 
55  auto createConnectionManager(
57  async_call,
58  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
59  std::chrono::milliseconds delay,
60  std::vector<shared_model::interface::types::HashType> initial_hashes,
61  const logger::LoggerManagerTreePtr &ordering_log_manager);
62 
67  auto createGate(
68  std::shared_ptr<ordering::OnDemandOrderingService> ordering_service,
69  std::shared_ptr<ordering::transport::OdOsNotification> network_client,
70  std::shared_ptr<ordering::cache::OrderingGateCache> cache,
71  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
72  proposal_factory,
73  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
74  std::function<std::chrono::milliseconds(
75  const synchronizer::SynchronizationEvent &)> delay_func,
76  size_t max_number_of_transactions,
77  const logger::LoggerManagerTreePtr &ordering_log_manager);
78 
83  auto createService(
84  size_t max_number_of_transactions,
85  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
86  proposal_factory,
87  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
88  const logger::LoggerManagerTreePtr &ordering_log_manager);
89 
90  rxcpp::composite_subscription sync_event_notifier_lifetime_;
91  rxcpp::composite_subscription commit_notifier_lifetime_;
92 
93  public:
97 
99 
120  std::shared_ptr<network::OrderingGate> initOrderingGate(
121  size_t max_number_of_transactions,
122  std::chrono::milliseconds delay,
123  std::vector<shared_model::interface::types::HashType> initial_hashes,
124  std::shared_ptr<
126  transaction_factory,
127  std::shared_ptr<shared_model::interface::TransactionBatchParser>
128  batch_parser,
129  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
130  transaction_batch_factory,
132  async_call,
133  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
134  proposal_factory,
135  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
136  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
137  std::function<std::chrono::milliseconds(
138  const synchronizer::SynchronizationEvent &)> delay_func,
139  logger::LoggerManagerTreePtr ordering_log_manager);
140 
142  std::shared_ptr<ordering::proto::OnDemandOrdering::Service> service;
143 
145  rxcpp::subjects::subject<decltype(std::declval<PeerCommunicationService>()
146  .onSynchronization())::value_type>
148  rxcpp::subjects::subject<decltype(
149  std::declval<iroha::ametsuchi::Storage>().on_commit())::value_type>
151 
152  private:
153  logger::LoggerPtr log_;
154 
155  boost::optional<consensus::Round> last_received_round_;
156 
157  std::vector<std::shared_ptr<shared_model::interface::Peer>>
158  current_peers_;
159 
161  enum RoundType { kCurrentRound, kNextRound, kRoundAfterNext, kCount };
162 
163  template <RoundType V>
164  using RoundTypeConstant = std::integral_constant<RoundType, V>;
165 
167  std::array<std::vector<size_t>, kCount> permutations_;
168 
170  // TODO andrei 08.11.2018 IR-1850 Refactor default_random_engine usages
171  // with platform-independent class
172  std::default_random_engine gen_;
173  };
174  } // namespace network
175 } // namespace iroha
176 
177 #endif // IROHA_ON_DEMAND_ORDERING_INIT_HPP
OnDemandOrderingInit(logger::LoggerPtr log)
Definition: on_demand_ordering_init.cpp:46
~OnDemandOrderingInit()
Definition: on_demand_ordering_init.cpp:305
Definition: proposal.hpp:17
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:14
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
Definition: on_demand_ordering_init.hpp:31
Definition: synchronizer_common.hpp:30
Definition: delay.hpp:27
Definition: async_grpc_client.hpp:25
std::shared_ptr< network::OrderingGate > initOrderingGate(size_t max_number_of_transactions, std::chrono::milliseconds delay, std::vector< shared_model::interface::types::HashType > initial_hashes, std::shared_ptr< ordering::transport::OnDemandOsServerGrpc::TransportFactoryType > transaction_factory, std::shared_ptr< shared_model::interface::TransactionBatchParser > batch_parser, std::shared_ptr< shared_model::interface::TransactionBatchFactory > transaction_batch_factory, std::shared_ptr< network::AsyncGrpcClient< google::protobuf::Empty >> async_call, std::shared_ptr< shared_model::interface::UnsafeProposalFactory > proposal_factory, std::shared_ptr< TransportFactoryType > proposal_transport_factory, std::shared_ptr< ametsuchi::TxPresenceCache > tx_cache, std::function< std::chrono::milliseconds(const synchronizer::SynchronizationEvent &)> delay_func, logger::LoggerManagerTreePtr ordering_log_manager)
Definition: on_demand_ordering_init.cpp:311
std::shared_ptr< ordering::proto::OnDemandOrdering::Service > service
gRPC service for ordering service
Definition: on_demand_ordering_init.hpp:142
rxcpp::subjects::subject< decltype(std::declval< PeerCommunicationService >).onSynchronization())::value_type > sync_event_notifier
commit notifier from peer communication service
Definition: on_demand_ordering_init.hpp:147
rxcpp::subjects::subject< decltype(std::declval< iroha::ametsuchi::Storage >).on_commit())::value_type > commit_notifier
Definition: on_demand_ordering_init.hpp:150