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 {
29  public transport::MstTransportGrpc::Service {
30  public:
31  using SenderFactory = std::function<
32  std::unique_ptr<transport::MstTransportGrpc::StubInterface>(
34  using TransportFactoryType =
38 
41  async_call,
42  std::shared_ptr<TransportFactoryType> transaction_factory,
43  std::shared_ptr<shared_model::interface::TransactionBatchParser>
44  batch_parser,
45  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
46  transaction_batch_factory,
47  std::shared_ptr<iroha::ametsuchi::TxPresenceCache> tx_presence_cache,
48  std::shared_ptr<Completer> mst_completer,
50  logger::LoggerPtr mst_state_logger,
52  boost::optional<SenderFactory> = boost::none);
53 
61  grpc::Status SendState(
62  ::grpc::ServerContext *context,
63  const ::iroha::network::transport::MstState *request,
64  ::google::protobuf::Empty *response) override;
65 
66  void subscribe(
67  std::shared_ptr<MstTransportNotification> notification) override;
68 
69  void sendState(const shared_model::interface::Peer &to,
70  ConstRefState providing_state) override;
71 
72  private:
77  deserializeTransactions(const transport::MstState *request);
78 
79  std::weak_ptr<MstTransportNotification> subscriber_;
80  std::shared_ptr<network::AsyncGrpcClient<google::protobuf::Empty>>
81  async_call_;
82  std::shared_ptr<TransportFactoryType> transaction_factory_;
83  std::shared_ptr<shared_model::interface::TransactionBatchParser>
84  batch_parser_;
85  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
86  batch_factory_;
87  std::shared_ptr<iroha::ametsuchi::TxPresenceCache> tx_presence_cache_;
89  std::shared_ptr<Completer> mst_completer_;
90  const std::string my_key_;
91 
92  logger::LoggerPtr mst_state_logger_;
93  logger::LoggerPtr log_;
95 
96  boost::optional<SenderFactory> sender_factory_;
97  };
98 
100  iroha::ConstRefState state,
101  const shared_model::crypto::PublicKey &sender_key,
103 
104  } // namespace network
105 } // namespace iroha
106 
107 #endif // IROHA_MST_TRANSPORT_GRPC_HPP
std::function< std::unique_ptr< transport::MstTransportGrpc::StubInterface >(const shared_model::interface::Peer &)> SenderFactory
Definition: mst_transport_grpc.hpp:33
Definition: peer.hpp:20
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: mst_transport_grpc.hpp:28
void sendStateAsync(const shared_model::interface::Peer &to, iroha::ConstRefState state, const shared_model::crypto::PublicKey &sender_key, AsyncGrpcClient< google::protobuf::Empty > &async_call)
Definition: mst_transport_grpc.cpp:168
Definition: block_query.hpp:14
Definition: mst_transport.hpp:36
Definition: public_key.hpp:16
Definition: async_grpc_client.hpp:25
Definition: transaction.hpp:23
std::vector< std::shared_ptr< Transaction >> SharedTxsCollectionType
Definition: transaction_sequence_common.hpp:27
ConstRefT< MstState > ConstRefState
Definition: mst_types.hpp:38