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 
12 #include "ametsuchi/storage.hpp"
15 #include "logger/logger_fwd.hpp"
20 #include "ordering.grpc.pb.h"
25 
26 namespace iroha {
27  namespace network {
28 
33  public:
34  using TransportFactoryType =
37  iroha::protocol::Proposal>;
38 
39  private:
44  auto createNotificationFactory(
46  async_call,
47  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
48  std::chrono::milliseconds delay,
49  const logger::LoggerManagerTreePtr &ordering_log_manager);
50 
56  auto createConnectionManager(
57  std::shared_ptr<ametsuchi::PeerQueryFactory> peer_query_factory,
59  async_call,
60  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
61  std::chrono::milliseconds delay,
62  std::vector<shared_model::interface::types::HashType> initial_hashes,
63  const logger::LoggerManagerTreePtr &ordering_log_manager);
64 
69  auto createGate(
70  std::shared_ptr<ordering::OnDemandOrderingService> ordering_service,
71  std::shared_ptr<ordering::transport::OdOsNotification> network_client,
72  std::shared_ptr<ordering::cache::OrderingGateCache> cache,
73  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
74  proposal_factory,
75  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
76  std::function<std::chrono::milliseconds(
77  const synchronizer::SynchronizationEvent &)> delay_func,
78  size_t max_number_of_transactions,
79  const logger::LoggerManagerTreePtr &ordering_log_manager);
80 
85  auto createService(
86  size_t max_number_of_transactions,
87  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
88  proposal_factory,
89  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
90  const logger::LoggerManagerTreePtr &ordering_log_manager);
91 
92  rxcpp::composite_subscription sync_event_notifier_lifetime_;
93  rxcpp::composite_subscription commit_notifier_lifetime_;
94 
95  public:
99 
101 
124  std::shared_ptr<network::OrderingGate> initOrderingGate(
125  size_t max_number_of_transactions,
126  std::chrono::milliseconds delay,
127  std::vector<shared_model::interface::types::HashType> initial_hashes,
128  // TODO 30.01.2019 lebdron: IR-263 Remove PeerQueryFactory
129  std::shared_ptr<ametsuchi::PeerQueryFactory> peer_query_factory,
130  std::shared_ptr<
132  transaction_factory,
133  std::shared_ptr<shared_model::interface::TransactionBatchParser>
134  batch_parser,
135  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
136  transaction_batch_factory,
138  async_call,
139  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
140  proposal_factory,
141  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
142  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
143  std::function<std::chrono::milliseconds(
144  const synchronizer::SynchronizationEvent &)> delay_func,
145  logger::LoggerManagerTreePtr ordering_log_manager);
146 
148  std::shared_ptr<ordering::proto::OnDemandOrdering::Service> service;
149 
151  rxcpp::subjects::subject<decltype(std::declval<PeerCommunicationService>()
152  .onSynchronization())::value_type>
154  rxcpp::subjects::subject<decltype(
155  std::declval<iroha::ametsuchi::Storage>().on_commit())::value_type>
157 
158  private:
159  logger::LoggerPtr log_;
160 
161  std::vector<std::shared_ptr<shared_model::interface::Peer>>
162  current_peers_;
163 
165  enum RoundType { kCurrentRound, kNextRound, kRoundAfterNext, kCount };
166 
167  template <RoundType V>
168  using RoundTypeConstant = std::integral_constant<RoundType, V>;
169 
171  std::array<std::vector<size_t>, kCount> permutations_;
172 
174  // TODO andrei 08.11.2018 IR-1850 Refactor default_random_engine usages
175  // with platform-independent class
176  std::default_random_engine gen_;
177  };
178  } // namespace network
179 } // namespace iroha
180 
181 #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:284
Definition: proposal.hpp:17
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:16
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
Definition: on_demand_ordering_init.hpp:32
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< ametsuchi::PeerQueryFactory > peer_query_factory, 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:290
Definition: synchronizer_common.hpp:30
Definition: delay.hpp:27
Definition: async_grpc_client.hpp:25
std::shared_ptr< ordering::proto::OnDemandOrdering::Service > service
gRPC service for ordering service
Definition: on_demand_ordering_init.hpp:148
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:153
rxcpp::subjects::subject< decltype(std::declval< iroha::ametsuchi::Storage >).on_commit())::value_type > commit_notifier
Definition: on_demand_ordering_init.hpp:156