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 
14 #include "logger/logger.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 
53  auto createConnectionManager(
54  std::shared_ptr<ametsuchi::PeerQueryFactory> peer_query_factory,
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 
65  auto createGate(
66  std::shared_ptr<ordering::OnDemandOrderingService> ordering_service,
67  std::shared_ptr<ordering::transport::OdOsNotification> network_client,
68  std::shared_ptr<ordering::cache::OrderingGateCache> cache,
69  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
70  proposal_factory,
71  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
72  consensus::Round initial_round,
73  std::function<std::chrono::seconds(
74  const synchronizer::SynchronizationEvent &)> delay_func);
75 
80  auto createService(
81  size_t max_size,
82  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
83  proposal_factory,
84  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache);
85 
86  public:
88 
112  std::shared_ptr<network::OrderingGate> initOrderingGate(
113  size_t max_size,
114  std::chrono::milliseconds delay,
115  std::vector<shared_model::interface::types::HashType> initial_hashes,
116  std::shared_ptr<ametsuchi::PeerQueryFactory> peer_query_factory,
117  std::shared_ptr<
119  transaction_factory,
120  std::shared_ptr<shared_model::interface::TransactionBatchParser>
121  batch_parser,
122  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
123  transaction_batch_factory,
125  async_call,
126  std::shared_ptr<shared_model::interface::UnsafeProposalFactory>
127  proposal_factory,
128  std::shared_ptr<TransportFactoryType> proposal_transport_factory,
129  std::shared_ptr<ametsuchi::TxPresenceCache> tx_cache,
130  consensus::Round initial_round,
131  std::function<std::chrono::seconds(
132  const synchronizer::SynchronizationEvent &)> delay_func);
133 
135  std::shared_ptr<ordering::proto::OnDemandOrdering::Service> service;
136 
138  rxcpp::subjects::subject<decltype(
139  std::declval<PeerCommunicationService>().on_commit())::value_type>
141 
142  private:
143  logger::Logger log_ = logger::log("OnDemandOrderingInit");
144 
145  std::vector<std::shared_ptr<shared_model::interface::Peer>>
146  current_peers_;
147 
149  enum RoundType { kCurrentRound, kNextRound, kRoundAfterNext, kCount };
150 
151  template <RoundType V>
152  using RoundTypeConstant = std::integral_constant<RoundType, V>;
153 
155  std::array<std::vector<size_t>, kCount> permutations_;
156 
158  // TODO andrei 08.11.2018 IR-1850 Refactor default_random_engine usages
159  // with platform-independent class
160  std::default_random_engine gen_;
161  };
162  } // namespace network
163 } // namespace iroha
164 
165 #endif // IROHA_ON_DEMAND_ORDERING_INIT_HPP
std::shared_ptr< network::OrderingGate > initOrderingGate(size_t max_size, 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, consensus::Round initial_round, std::function< std::chrono::seconds(const synchronizer::SynchronizationEvent &)> delay_func)
Definition: on_demand_ordering_init.cpp:255
~OnDemandOrderingInit()
Definition: on_demand_ordering_init.cpp:250
Definition: proposal.hpp:17
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block_query.hpp:16
Logger log(const std::string &tag)
Definition: logger.cpp:48
Definition: on_demand_ordering_init.hpp:30
rxcpp::subjects::subject< decltype(std::declval< PeerCommunicationService >).on_commit())::value_type > notifier
commit notifier from peer communication service
Definition: on_demand_ordering_init.hpp:140
Definition: round.hpp:31
Definition: synchronizer_common.hpp:38
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:135