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 <unordered_map>
14 
19 #include "logger/logger_fwd.hpp"
21 
22 namespace iroha {
23  namespace consensus {
24  namespace yac {
25 
30  class NetworkImpl : public YacNetwork, public proto::Yac::Service {
31  public:
32  explicit NetworkImpl(
34  async_call,
35  std::function<std::unique_ptr<proto::Yac::StubInterface>(
36  const shared_model::interface::Peer &)> client_creator,
37  logger::LoggerPtr log);
38 
39  void subscribe(
40  std::shared_ptr<YacNetworkNotifications> handler) override;
41 
43  const std::vector<VoteMessage> &state) override;
44 
50  grpc::Status SendState(
51  ::grpc::ServerContext *context,
52  const ::iroha::consensus::yac::proto::State *request,
53  ::google::protobuf::Empty *response) override;
54 
55  private:
61  void createPeerConnection(const shared_model::interface::Peer &peer);
62 
67  std::unique_ptr<proto::Yac::StubInterface>>
68  peers_;
69 
73  std::weak_ptr<YacNetworkNotifications> handler_;
74 
78  std::shared_ptr<network::AsyncGrpcClient<google::protobuf::Empty>>
79  async_call_;
80 
84  std::function<std::unique_ptr<proto::Yac::StubInterface>(
86  client_creator_;
87 
88  logger::LoggerPtr log_;
89  };
90 
91  } // namespace yac
92  } // namespace consensus
93 } // namespace iroha
94 
95 #endif // IROHA_NETWORK_IMPL_HPP
Definition: yac_network_interface.hpp:35
std::string AddressType
Type of peer address.
Definition: types.hpp:41
Definition: peer.hpp:18
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:16
Definition: network_impl.hpp:30
void sendState(const shared_model::interface::Peer &to, const std::vector< VoteMessage > &state) override
Definition: network_impl.cpp:38
void subscribe(std::shared_ptr< YacNetworkNotifications > handler) override
Definition: network_impl.cpp:33
grpc::Status SendState(::grpc::ServerContext *context, const ::iroha::consensus::yac::proto::State *request,::google::protobuf::Empty *response) override
Definition: network_impl.cpp:56
NetworkImpl(std::shared_ptr< network::AsyncGrpcClient< google::protobuf::Empty >> async_call, std::function< std::unique_ptr< proto::Yac::StubInterface >(const shared_model::interface::Peer &)> client_creator, logger::LoggerPtr log)
Definition: network_impl.cpp:23
Definition: async_grpc_client.hpp:25