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 <rxcpp/rx-lite.hpp>
10 #include "ametsuchi/storage.hpp"
13 #include "logger/logger_fwd.hpp"
18 #include "ordering.grpc.pb.h"
23 
24 namespace iroha {
25  namespace network {
26 
31  public:
32  using TransportFactoryType =
35  iroha::protocol::Proposal>;
36 
37  private:
42  auto createNotificationFactory(
44  async_call,
45  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
46  std::chrono::milliseconds delay,
47  const logger::LoggerManagerTreePtr &ordering_log_manager);
48 
54  auto createConnectionManager(
56  async_call,
57  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
58  std::chrono::milliseconds delay,
59  std::vector<shared_model::interface::types::HashType> initial_hashes,
60  const logger::LoggerManagerTreePtr &ordering_log_manager);
61 
66  auto createGate(
67  std::shared_ptr<ordering::OnDemandOrderingService> ordering_service,
68  std::shared_ptr<ordering::transport::OdOsNotification> network_client,
69  std::shared_ptr<ordering::cache::OrderingGateCache> cache,
70  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
71  proposal_factory,
72  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
73  std::shared_ptr<ordering::ProposalCreationStrategy> creation_strategy,
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  std::shared_ptr<ordering::ProposalCreationStrategy> creation_strategy,
89  const logger::LoggerManagerTreePtr &ordering_log_manager);
90 
91  rxcpp::composite_subscription sync_event_notifier_lifetime_;
92  rxcpp::composite_subscription commit_notifier_lifetime_;
93 
94  public:
98 
100 
123  std::shared_ptr<network::OrderingGate> initOrderingGate(
124  size_t max_number_of_transactions,
125  std::chrono::milliseconds delay,
126  std::vector<shared_model::interface::types::HashType> initial_hashes,
127  std::shared_ptr<
129  transaction_factory,
130  std::shared_ptr<shared_model::interface::TransactionBatchParser>
131  batch_parser,
132  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
133  transaction_batch_factory,
135  async_call,
136  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
137  proposal_factory,
138  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
139  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
140  std::shared_ptr<ordering::ProposalCreationStrategy> creation_strategy,
141  std::function<std::chrono::milliseconds(
142  const synchronizer::SynchronizationEvent &)> delay_func,
143  logger::LoggerManagerTreePtr ordering_log_manager);
144 
146  std::shared_ptr<ordering::proto::OnDemandOrdering::Service> service;
147 
149  rxcpp::subjects::subject<decltype(std::declval<PeerCommunicationService>()
150  .onSynchronization())::value_type>
152  rxcpp::subjects::subject<decltype(
153  std::declval<iroha::ametsuchi::Storage>().on_commit())::value_type>
155 
156  private:
157  logger::LoggerPtr log_;
158 
159  boost::optional<consensus::Round> last_received_round_;
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  };
173  } // namespace network
174 } // namespace iroha
175 
176 #endif // IROHA_ON_DEMAND_ORDERING_INIT_HPP
OnDemandOrderingInit(logger::LoggerPtr log)
Definition: on_demand_ordering_init.cpp:37
~OnDemandOrderingInit()
Definition: on_demand_ordering_init.cpp:300
Definition: proposal.hpp:17
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:15
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
Definition: on_demand_ordering_init.hpp:30
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:306
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:146
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:151
rxcpp::subjects::subject< decltype(std::declval< iroha::ametsuchi::Storage >).on_commit())::value_type > commit_notifier
Definition: on_demand_ordering_init.hpp:154