hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
on_demand_os_client_grpc.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_ON_DEMAND_OS_TRANSPORT_CLIENT_GRPC_HPP
7 #define IROHA_ON_DEMAND_OS_TRANSPORT_CLIENT_GRPC_HPP
8 
10 
11 #include "common/result.hpp"
13 #include "logger/logger_fwd.hpp"
14 #include "ordering.grpc.pb.h"
16 
17 namespace iroha {
18  namespace network {
19  template <typename Service>
20  class ClientFactory;
21  }
22  namespace ordering {
23  namespace transport {
24 
29  public:
30  using TransportFactoryType =
33  iroha::protocol::Proposal>;
34  using TimepointType = std::chrono::system_clock::time_point;
35  using TimeoutType = std::chrono::milliseconds;
36 
42  std::shared_ptr<proto::OnDemandOrdering::StubInterface> stub,
43  std::shared_ptr<TransportFactoryType> proposal_factory,
44  std::function<TimepointType()> time_provider,
45  std::chrono::milliseconds proposal_request_timeout,
47  std::function<void(ProposalEvent)> callback);
48 
49  void onBatches(CollectionType batches) override;
50 
51  void onRequestProposal(consensus::Round round) override;
52 
53  private:
54  logger::LoggerPtr log_;
55  std::shared_ptr<proto::OnDemandOrdering::StubInterface> stub_;
56  std::shared_ptr<TransportFactoryType> proposal_factory_;
57  std::function<TimepointType()> time_provider_;
58  std::chrono::milliseconds proposal_request_timeout_;
59  std::function<void(ProposalEvent)> callback_;
60  std::weak_ptr<grpc::ClientContext> context_;
61  };
62 
64  public:
65  using Service = proto::OnDemandOrdering;
67 
70  std::shared_ptr<TransportFactoryType> proposal_factory,
71  std::function<OnDemandOsClientGrpc::TimepointType()> time_provider,
72  OnDemandOsClientGrpc::TimeoutType proposal_request_timeout,
73  logger::LoggerPtr client_log,
74  std::unique_ptr<ClientFactory> client_factory,
75  std::function<void(ProposalEvent)> callback);
76 
78  create(const shared_model::interface::Peer &to) override;
79 
80  private:
81  std::shared_ptr<TransportFactoryType> proposal_factory_;
82  std::function<OnDemandOsClientGrpc::TimepointType()> time_provider_;
83  std::chrono::milliseconds proposal_request_timeout_;
84  logger::LoggerPtr client_log_;
85  std::unique_ptr<ClientFactory> client_factory_;
86  std::function<void(ProposalEvent)> callback_;
87  };
88 
89  } // namespace transport
90  } // namespace ordering
91 } // namespace iroha
92 
93 #endif // IROHA_ON_DEMAND_OS_TRANSPORT_CLIENT_GRPC_HPP
Definition: peer.hpp:20
Definition: on_demand_common.hpp:27
Definition: result_fwd.hpp:27
Definition: proposal.hpp:17
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: on_demand_os_transport.hpp:64
Definition: on_demand_os_client_grpc.hpp:28
Definition: block_query.hpp:15
std::chrono::system_clock::time_point TimepointType
Definition: on_demand_os_client_grpc.hpp:34
std::chrono::milliseconds TimeoutType
Definition: on_demand_os_client_grpc.hpp:35
Definition: on_demand_os_transport.hpp:32
proto::OnDemandOrdering Service
Definition: on_demand_os_client_grpc.hpp:65
Definition: round.hpp:31
std::vector< TransactionBatchType > CollectionType
Definition: on_demand_os_transport.hpp:43
Definition: mst_transport_grpc.hpp:29
Definition: on_demand_os_client_grpc.hpp:63