hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
network_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_NETWORK_IMPL_HPP
7 #define IROHA_NETWORK_IMPL_HPP
8 
9 #include "consensus/yac/transport/yac_network_interface.hpp" // for YacNetwork
10 #include "yac.grpc.pb.h"
11 
12 #include <memory>
13 #include <mutex>
14 #include <unordered_map>
15 
20 #include "logger/logger_fwd.hpp"
23 
24 namespace iroha {
25  namespace consensus {
26  namespace yac {
27 
32  class NetworkImpl : public YacNetwork, public proto::Yac::Service {
33  public:
34  using Service = proto::Yac;
36 
37  explicit NetworkImpl(
39  async_call,
40  std::unique_ptr<iroha::network::ClientFactory<
41  ::iroha::consensus::yac::proto::Yac>> client_factory,
42  logger::LoggerPtr log);
43 
44  void subscribe(
45  std::shared_ptr<YacNetworkNotifications> handler) override;
46 
48  const std::vector<VoteMessage> &state) override;
49 
56  ::grpc::ServerContext *context,
57  const ::iroha::consensus::yac::proto::State *request,
58  ::google::protobuf::Empty *response) override;
59 
60  void stop() override;
61 
62  private:
66  std::weak_ptr<YacNetworkNotifications> handler_;
67 
71  std::shared_ptr<network::AsyncGrpcClient<google::protobuf::Empty>>
72  async_call_;
73 
77  std::unique_ptr<ClientFactory> client_factory_;
78 
79  std::mutex stop_mutex_;
80  bool stop_requested_{false};
81 
82  logger::LoggerPtr log_;
83  };
84 
85  } // namespace yac
86  } // namespace consensus
87 } // namespace iroha
88 
89 #endif // IROHA_NETWORK_IMPL_HPP
Definition: yac_network_interface.hpp:35
Definition: peer.hpp:20
void stop() override
Prevent any new outgoing network activity. Be passive.
Definition: network_impl.cpp:39
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
proto::Yac Service
Definition: network_impl.hpp:34
Definition: block_query.hpp:15
Definition: network_impl.hpp:32
void sendState(const shared_model::interface::Peer &to, const std::vector< VoteMessage > &state) override
Definition: network_impl.cpp:44
void subscribe(std::shared_ptr< YacNetworkNotifications > handler) override
Definition: network_impl.cpp:34
NetworkImpl(std::shared_ptr< network::AsyncGrpcClient< google::protobuf::Empty >> async_call, std::unique_ptr< iroha::network::ClientFactory< ::iroha::consensus::yac::proto::Yac >> client_factory, logger::LoggerPtr log)
Definition: network_impl.cpp:25
Definition: on_demand_ordering_init.hpp:44
Status
Definition: status.hpp:12
Definition: mst_transport_grpc.hpp:29
grpc::Status SendState(::grpc::ServerContext *context, const ::iroha::consensus::yac::proto::State *request, ::google::protobuf::Empty *response) override
Definition: network_impl.cpp:76