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::shared_ptr<ordering::ProposalCreationStrategy> creation_strategy,
75  std::function<std::chrono::milliseconds(
76  const synchronizer::SynchronizationEvent &)> delay_func,
77  size_t max_number_of_transactions,
78  const logger::LoggerManagerTreePtr &ordering_log_manager);
79 
84  auto createService(
85  size_t max_number_of_transactions,
86  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
87  proposal_factory,
88  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
89  std::shared_ptr<ordering::ProposalCreationStrategy> creation_strategy,
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  std::shared_ptr<
130  transaction_factory,
131  std::shared_ptr<shared_model::interface::TransactionBatchParser>
132  batch_parser,
133  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
134  transaction_batch_factory,
136  async_call,
137  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
138  proposal_factory,
139  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
140  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
141  std::shared_ptr<ordering::ProposalCreationStrategy> creation_strategy,
142  std::function<std::chrono::milliseconds(
143  const synchronizer::SynchronizationEvent &)> delay_func,
144  logger::LoggerManagerTreePtr ordering_log_manager);
145 
147  std::shared_ptr<ordering::proto::OnDemandOrdering::Service> service;
148 
150  rxcpp::subjects::subject<decltype(std::declval<PeerCommunicationService>()
151  .onSynchronization())::value_type>
153  rxcpp::subjects::subject<decltype(
154  std::declval<iroha::ametsuchi::Storage>().on_commit())::value_type>
156 
157  private:
158  logger::LoggerPtr log_;
159 
160  boost::optional<consensus::Round> last_received_round_;
161 
162  std::vector<std::shared_ptr<shared_model::interface::Peer>>
163  current_peers_;
164 
166  enum RoundType { kCurrentRound, kNextRound, kRoundAfterNext, kCount };
167 
168  template <RoundType V>
169  using RoundTypeConstant = std::integral_constant<RoundType, V>;
170 
172  std::array<std::vector<size_t>, kCount> permutations_;
173 
175  // TODO andrei 08.11.2018 IR-1850 Refactor default_random_engine usages
176  // with platform-independent class
177  std::default_random_engine gen_;
178  };
179  } // namespace network
180 } // namespace iroha
181 
182 #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:309
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
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::shared_ptr< ordering::ProposalCreationStrategy > creation_strategy, std::function< std::chrono::milliseconds(const synchronizer::SynchronizationEvent &)> delay_func, logger::LoggerManagerTreePtr ordering_log_manager)
Definition: on_demand_ordering_init.cpp:315
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:147
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:152
rxcpp::subjects::subject< decltype(std::declval< iroha::ametsuchi::Storage >).on_commit())::value_type > commit_notifier
Definition: on_demand_ordering_init.hpp:155