hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
mst_transport_grpc.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_MST_TRANSPORT_GRPC_HPP
7 #define IROHA_MST_TRANSPORT_GRPC_HPP
8 
9 #include "mst.grpc.pb.h"
11 
17 #include "logger/logger_fwd.hpp"
20 
21 namespace iroha {
22 
23  namespace ametsuchi {
24  class TxPresenceCache;
25  }
26 
27  namespace network {
28  template <typename Service>
30 
32  public transport::MstTransportGrpc::Service {
33  public:
34  using TransportFactoryType =
38 
39  using Service = transport::MstTransportGrpc;
41 
44  async_call,
45  std::shared_ptr<TransportFactoryType> transaction_factory,
46  std::shared_ptr<shared_model::interface::TransactionBatchParser>
47  batch_parser,
48  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
49  transaction_batch_factory,
50  std::shared_ptr<iroha::ametsuchi::TxPresenceCache> tx_presence_cache,
51  std::shared_ptr<Completer> mst_completer,
52  shared_model::interface::types::PublicKeyHexStringView my_key,
53  logger::LoggerPtr mst_state_logger,
55  std::unique_ptr<MstClientFactory> client_factory);
56 
64  grpc::Status SendState(
65  ::grpc::ServerContext *context,
66  const ::iroha::network::transport::MstState *request,
67  ::google::protobuf::Empty *response) override;
68 
69  void subscribe(
70  std::shared_ptr<MstTransportNotification> notification) override;
71 
72  rxcpp::observable<bool> sendState(
73  std::shared_ptr<shared_model::interface::Peer const> to,
74  MstState const &providing_state) override;
75 
76  private:
77  std::weak_ptr<MstTransportNotification> subscriber_;
78  std::shared_ptr<network::AsyncGrpcClient<google::protobuf::Empty>>
79  async_call_;
80  std::shared_ptr<TransportFactoryType> transaction_factory_;
81  std::shared_ptr<shared_model::interface::TransactionBatchParser>
82  batch_parser_;
83  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
84  batch_factory_;
85  std::shared_ptr<iroha::ametsuchi::TxPresenceCache> tx_presence_cache_;
87  std::shared_ptr<Completer> mst_completer_;
88  std::string const my_key_;
89 
90  logger::LoggerPtr mst_state_logger_;
91  logger::LoggerPtr log_;
93 
94  std::shared_ptr<MstClientFactory> client_factory_;
95  };
96 
97  void sendStateAsync(
98  MstState const &state,
99  shared_model::interface::types::PublicKeyHexStringView sender_key,
100  transport::MstTransportGrpc::StubInterface &client_stub,
102  std::function<void(grpc::Status &, google::protobuf::Empty &)>
103  on_response = {});
104 
105  } // namespace network
106 } // namespace iroha
107 
108 #endif // IROHA_MST_TRANSPORT_GRPC_HPP
Definition: mst_state.hpp:76
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
transport::MstTransportGrpc Service
Definition: mst_transport_grpc.hpp:39
Definition: mst_transport_grpc.hpp:31
void sendStateAsync(MstState const &state, shared_model::interface::types::PublicKeyHexStringView sender_key, transport::MstTransportGrpc::StubInterface &client_stub, AsyncGrpcClient< google::protobuf::Empty > &async_call, std::function< void(grpc::Status &, google::protobuf::Empty &)> on_response={})
Definition: block_query.hpp:15
Definition: mst_transport.hpp:42
Definition: on_demand_ordering_init.hpp:44
Status
Definition: status.hpp:12
Definition: mst_transport_grpc.hpp:29
Definition: on_demand_ordering_init.hpp:33
Definition: transaction.hpp:23