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 <rxcpp/rx-lite.hpp>
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(
58  async_call,
59  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
60  std::chrono::milliseconds delay,
61  std::vector<shared_model::interface::types::HashType> initial_hashes,
62  const logger::LoggerManagerTreePtr &ordering_log_manager);
63 
68  auto createGate(
69  std::shared_ptr<ordering::OnDemandOrderingService> ordering_service,
70  std::shared_ptr<ordering::transport::OdOsNotification> network_client,
71  std::shared_ptr<ordering::cache::OrderingGateCache> cache,
72  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
73  proposal_factory,
74  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
75  std::shared_ptr<ordering::ProposalCreationStrategy> creation_strategy,
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  std::shared_ptr<ordering::ProposalCreationStrategy> creation_strategy,
91  const logger::LoggerManagerTreePtr &ordering_log_manager);
92 
93  rxcpp::composite_subscription sync_event_notifier_lifetime_;
94  rxcpp::composite_subscription commit_notifier_lifetime_;
95 
96  public:
100 
102 
125  std::shared_ptr<network::OrderingGate> initOrderingGate(
126  size_t max_number_of_transactions,
127  std::chrono::milliseconds delay,
128  std::vector<shared_model::interface::types::HashType> initial_hashes,
129  std::shared_ptr<
131  transaction_factory,
132  std::shared_ptr<shared_model::interface::TransactionBatchParser>
133  batch_parser,
134  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
135  transaction_batch_factory,
137  async_call,
138  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
139  proposal_factory,
140  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
141  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
142  std::shared_ptr<ordering::ProposalCreationStrategy> creation_strategy,
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  boost::optional<consensus::Round> last_received_round_;
162 
163  std::vector<std::shared_ptr<shared_model::interface::Peer>>
164  current_peers_;
165 
167  enum RoundType { kCurrentRound, kNextRound, kRoundAfterNext, kCount };
168 
169  template <RoundType V>
170  using RoundTypeConstant = std::integral_constant<RoundType, V>;
171 
173  std::array<std::vector<size_t>, kCount> permutations_;
174 
176  // TODO andrei 08.11.2018 IR-1850 Refactor default_random_engine usages
177  // with platform-independent class
178  std::default_random_engine gen_;
179  };
180  } // namespace network
181 } // namespace iroha
182 
183 #endif // IROHA_ON_DEMAND_ORDERING_INIT_HPP
OnDemandOrderingInit(logger::LoggerPtr log)
Definition: on_demand_ordering_init.cpp:36
~OnDemandOrderingInit()
Definition: on_demand_ordering_init.cpp:303
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: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< 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:309
Definition: synchronizer_common.hpp:28
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