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 
18 #include "logger/logger.hpp"
20 
21 namespace iroha {
22  namespace consensus {
23  namespace yac {
24 
25  struct CommitMessage;
26  struct RejectMessage;
27  struct VoteMessage;
28 
33  class NetworkImpl : public YacNetwork, public proto::Yac::Service {
34  public:
35  explicit NetworkImpl(
37  async_call);
38  void subscribe(
39  std::shared_ptr<YacNetworkNotifications> handler) override;
40 
42  const std::vector<VoteMessage> &state) override;
43 
49  grpc::Status SendState(
50  ::grpc::ServerContext *context,
51  const ::iroha::consensus::yac::proto::State *request,
52  ::google::protobuf::Empty *response) override;
53 
54  private:
60  void createPeerConnection(const shared_model::interface::Peer &peer);
61 
66  std::unique_ptr<proto::Yac::StubInterface>>
67  peers_;
68 
72  std::weak_ptr<YacNetworkNotifications> handler_;
73 
77  std::shared_ptr<network::AsyncGrpcClient<google::protobuf::Empty>>
78  async_call_;
79  };
80 
81  } // namespace yac
82  } // namespace consensus
83 } // namespace iroha
84 
85 #endif // IROHA_NETWORK_IMPL_HPP
Definition: yac_network_interface.hpp:35
std::string AddressType
Type of peer address.
Definition: types.hpp:43
Definition: peer.hpp:18
Definition: block_query.hpp:16
Definition: network_impl.hpp:33
void sendState(const shared_model::interface::Peer &to, const std::vector< VoteMessage > &state) override
Definition: network_impl.cpp:33
void subscribe(std::shared_ptr< YacNetworkNotifications > handler) override
Definition: network_impl.cpp:28
grpc::Status SendState(::grpc::ServerContext *context, const ::iroha::consensus::yac::proto::State *request,::google::protobuf::Empty *response) override
Definition: network_impl.cpp:51
NetworkImpl(std::shared_ptr< network::AsyncGrpcClient< google::protobuf::Empty >> async_call)
Definition: network_impl.cpp:23
Definition: async_grpc_client.hpp:25