Kagome
Polkadot Runtime Engine in C++17
router_libp2p.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_NETWORK_IMPL_ROUTER_LIBP2P_HPP
7 #define KAGOME_NETWORK_IMPL_ROUTER_LIBP2P_HPP
8 
9 #include "network/router.hpp"
10 
13 #include "libp2p/connection/loopback_stream.hpp"
14 #include "libp2p/host/host.hpp"
15 #include "libp2p/multi/multiaddress.hpp"
16 #include "libp2p/protocol/ping.hpp"
21 
22 namespace kagome::application {
23  class ChainSpec;
24 }
25 
26 namespace kagome::blockchain {
27  class BlockStorage;
28 }
29 
30 namespace kagome::network {
31  class RouterLibp2p : public Router,
32  public std::enable_shared_from_this<RouterLibp2p> {
33  public:
35  std::shared_ptr<application::AppStateManager> app_state_manager,
36  libp2p::Host &host,
37  const application::AppConfiguration &app_config,
38  const OwnPeerInfo &own_info,
39  const BootstrapNodes &bootstrap_nodes,
40  std::shared_ptr<libp2p::protocol::Ping> ping_proto,
41  std::shared_ptr<network::ProtocolFactory> protocol_factory);
42 
43  ~RouterLibp2p() override = default;
44 
46  bool prepare();
47 
49  bool start();
50 
52  void stop();
53 
54  std::shared_ptr<BlockAnnounceProtocol> getBlockAnnounceProtocol()
55  const override;
56  std::shared_ptr<PropagateTransactionsProtocol>
57  getPropagateTransactionsProtocol() const override;
58  std::shared_ptr<StateProtocol> getStateProtocol() const override;
59  std::shared_ptr<SyncProtocol> getSyncProtocol() const override;
60  std::shared_ptr<GrandpaProtocol> getGrandpaProtocol() const override;
61  std::shared_ptr<CollationProtocol> getCollationProtocol() const override;
62  std::shared_ptr<ReqCollationProtocol> getReqCollationProtocol()
63  const override;
64 
65  std::shared_ptr<libp2p::protocol::Ping> getPingProtocol() const override;
66 
67  private:
75  outcome::result<void> appendPeerIdToAddress(
76  libp2p::multi::Multiaddress &address) const;
77 
78  std::shared_ptr<application::AppStateManager> app_state_manager_;
83  std::shared_ptr<libp2p::protocol::Ping> ping_protocol_;
84  std::shared_ptr<network::ProtocolFactory> protocol_factory_;
85 
86  std::shared_ptr<BlockAnnounceProtocol> block_announce_protocol_;
87  std::shared_ptr<GrandpaProtocol> grandpa_protocol_;
88  std::shared_ptr<PropagateTransactionsProtocol>
90  std::shared_ptr<StateProtocol> state_protocol_;
91  std::shared_ptr<SyncProtocol> sync_protocol_;
92  std::shared_ptr<CollationProtocol> collation_protocol_;
93  std::shared_ptr<ReqCollationProtocol> req_collation_protocol_;
94  };
95 
96 } // namespace kagome::network
97 
98 #endif // KAGOME_NETWORK_IMPL_ROUTER_LIBP2P_HPP
std::shared_ptr< libp2p::protocol::Ping > ping_protocol_
std::shared_ptr< SyncProtocol > sync_protocol_
const application::AppConfiguration & app_config_
std::shared_ptr< BlockAnnounceProtocol > block_announce_protocol_
std::shared_ptr< ReqCollationProtocol > req_collation_protocol_
std::shared_ptr< CollationProtocol > collation_protocol_
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
const OwnPeerInfo & own_info_
std::shared_ptr< PropagateTransactionsProtocol > propagate_transaction_protocol_
std::shared_ptr< application::AppStateManager > app_state_manager_
std::shared_ptr< GrandpaProtocol > grandpa_protocol_
std::shared_ptr< StateProtocol > state_protocol_
std::shared_ptr< network::ProtocolFactory > protocol_factory_