6 #ifndef KAGOME_NETWORK_STATEPROTOCOLIMPL 7 #define KAGOME_NETWORK_STATEPROTOCOLIMPL 13 #include <libp2p/connection/stream.hpp> 14 #include <libp2p/host/host.hpp> 29 public std::enable_shared_from_this<StateProtocolImpl> {
33 std::shared_ptr<StateProtocolObserver> state_observer);
35 bool start()
override;
45 std::function<
void(outcome::result<std::shared_ptr<Stream>>)> &&cb)
50 std::function<
void(outcome::result<StateResponse>)>
51 &&response_handler)
override;
60 std::function<
void(outcome::result<void>)> &&cb);
63 std::shared_ptr<Stream> stream,
64 std::function<
void(outcome::result<StateResponse>)> &&response_handler);
76 #endif // KAGOME_NETWORK_STATEPROTOCOLIMPL
StateProtocolImpl(libp2p::Host &host, const application::ChainSpec &chain_spec, std::shared_ptr< StateProtocolObserver > state_observer)
void writeResponse(std::shared_ptr< Stream > stream, StateResponse state_response)
void writeRequest(std::shared_ptr< Stream > stream, StateRequest state_request, std::function< void(outcome::result< void >)> &&cb)
const libp2p::peer::Protocol protocol_
libp2p::peer::PeerInfo PeerInfo
libp2p::peer::Protocol Protocol
libp2p::peer::PeerId PeerId
void newOutgoingStream(const PeerInfo &peer_info, std::function< void(outcome::result< std::shared_ptr< Stream >>)> &&cb) override
Class for communication via /{chainType}/state/2 according to state protocol specification https://sp...
std::shared_ptr< soralog::Logger > Logger
void request(const PeerId &peer_id, StateRequest state_request, std::function< void(outcome::result< StateResponse >)> &&response_handler) override
Make async request to peer and return response in callback.
libp2p::connection::Stream Stream
void readRequest(std::shared_ptr< Stream > stream)
void onIncomingStream(std::shared_ptr< Stream > stream) override
Logger createLogger(const std::string &tag)
std::shared_ptr< StateProtocolObserver > state_observer_
const std::string & protocolName() const override
static const auto kStateProtocolName
void readResponse(std::shared_ptr< Stream > stream, std::function< void(outcome::result< StateResponse >)> &&response_handler)