Kagome
Polkadot Runtime Engine in C++17
kagome::network::StateProtocolImpl Class Referencefinal

#include <state_protocol_impl.hpp>

Inheritance diagram for kagome::network::StateProtocolImpl:
Collaboration diagram for kagome::network::StateProtocolImpl:

Public Member Functions

 StateProtocolImpl (libp2p::Host &host, const application::ChainSpec &chain_spec, std::shared_ptr< StateProtocolObserver > state_observer)
 
bool start () override
 
bool stop () override
 
const std::string & protocolName () const override
 
void onIncomingStream (std::shared_ptr< Stream > stream) override
 
void newOutgoingStream (const PeerInfo &peer_info, std::function< void(outcome::result< std::shared_ptr< Stream >>)> &&cb) override
 
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. More...
 
void readRequest (std::shared_ptr< Stream > stream)
 
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)
 
void readResponse (std::shared_ptr< Stream > stream, std::function< void(outcome::result< StateResponse >)> &&response_handler)
 
- Public Member Functions inherited from kagome::network::ProtocolBase
 ProtocolBase ()=default
 
 ProtocolBase (ProtocolBase &&) noexcept=delete
 
 ProtocolBase (const ProtocolBase &)=delete
 
virtual ~ProtocolBase ()=default
 
ProtocolBaseoperator= (ProtocolBase &&) noexcept=delete
 
ProtocolBaseoperator= (ProtocolBase const &)=delete
 

Private Attributes

libp2p::Host & host_
 
std::shared_ptr< StateProtocolObserverstate_observer_
 
const libp2p::peer::Protocol protocol_
 
log::Logger log_ = log::createLogger("StateProtocol", "state_protocol")
 

Static Private Attributes

static const auto kStateProtocolName = "StateProtocol"s
 

Detailed Description

Definition at line 27 of file state_protocol_impl.hpp.

Constructor & Destructor Documentation

kagome::network::StateProtocolImpl::StateProtocolImpl ( libp2p::Host &  host,
const application::ChainSpec chain_spec,
std::shared_ptr< StateProtocolObserver state_observer 
)

Definition at line 16 of file state_protocol_impl.cpp.

Member Function Documentation

void kagome::network::StateProtocolImpl::newOutgoingStream ( const PeerInfo peer_info)
overridevirtual

Implements kagome::network::ProtocolBase.

Definition at line 57 of file state_protocol_impl.cpp.

void kagome::network::StateProtocolImpl::onIncomingStream ( std::shared_ptr< Stream stream)
overridevirtual

Implements kagome::network::ProtocolBase.

Definition at line 51 of file state_protocol_impl.cpp.

const std::string& kagome::network::StateProtocolImpl::protocolName ( ) const
inlineoverridevirtual

Implements kagome::network::ProtocolBase.

Definition at line 38 of file state_protocol_impl.hpp.

void kagome::network::StateProtocolImpl::readRequest ( std::shared_ptr< Stream stream)

Definition at line 94 of file state_protocol_impl.cpp.

void kagome::network::StateProtocolImpl::readResponse ( std::shared_ptr< Stream stream,
std::function< void(outcome::result< StateResponse >)> &&  response_handler 
)

Definition at line 298 of file state_protocol_impl.cpp.

void kagome::network::StateProtocolImpl::request ( const PeerId peer_id,
StateRequest  state_request,
std::function< void(outcome::result< StateResponse >)> &&  response_handler 
)
overridevirtual

Make async request to peer and return response in callback.

Parameters
peer_idof a peer to make request to
state_requesta request content
response_handlera callback to call when response received

Implements kagome::network::StateProtocol.

Definition at line 163 of file state_protocol_impl.cpp.

bool kagome::network::StateProtocolImpl::start ( )
overridevirtual

Implements kagome::network::ProtocolBase.

Definition at line 26 of file state_protocol_impl.cpp.

bool kagome::network::StateProtocolImpl::stop ( )
overridevirtual

Implements kagome::network::ProtocolBase.

Definition at line 47 of file state_protocol_impl.cpp.

void kagome::network::StateProtocolImpl::writeRequest ( std::shared_ptr< Stream stream,
StateRequest  state_request,
std::function< void(outcome::result< void >)> &&  cb 
)

Definition at line 254 of file state_protocol_impl.cpp.

void kagome::network::StateProtocolImpl::writeResponse ( std::shared_ptr< Stream stream,
StateResponse  state_response 
)

Definition at line 225 of file state_protocol_impl.cpp.

Member Data Documentation

libp2p::Host& kagome::network::StateProtocolImpl::host_
private

Definition at line 68 of file state_protocol_impl.hpp.

const auto kagome::network::StateProtocolImpl::kStateProtocolName = "StateProtocol"s
inlinestaticprivate

Definition at line 67 of file state_protocol_impl.hpp.

log::Logger kagome::network::StateProtocolImpl::log_ = log::createLogger("StateProtocol", "state_protocol")
private

Definition at line 71 of file state_protocol_impl.hpp.

const libp2p::peer::Protocol kagome::network::StateProtocolImpl::protocol_
private

Definition at line 70 of file state_protocol_impl.hpp.

std::shared_ptr<StateProtocolObserver> kagome::network::StateProtocolImpl::state_observer_
private

Definition at line 69 of file state_protocol_impl.hpp.


The documentation for this class was generated from the following files: