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

#include <sync_protocol_impl.hpp>

Inheritance diagram for kagome::network::SyncProtocolImpl:
Collaboration diagram for kagome::network::SyncProtocolImpl:

Public Member Functions

 SyncProtocolImpl (libp2p::Host &host, const application::ChainSpec &chain_spec, std::shared_ptr< SyncProtocolObserver > sync_observer, std::shared_ptr< ReputationRepository > reputation_repository)
 
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, BlocksRequest block_request, std::function< void(outcome::result< BlocksResponse >)> &&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, const BlocksResponse &block_response)
 
void writeRequest (std::shared_ptr< Stream > stream, BlocksRequest block_request, std::function< void(outcome::result< void >)> &&cb)
 
void readResponse (std::shared_ptr< Stream > stream, std::function< void(outcome::result< BlocksResponse >)> &&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

ProtocolBaseImpl base_
 
std::shared_ptr< SyncProtocolObserversync_observer_
 
std::shared_ptr< ReputationRepositoryreputation_repository_
 
detail::BlocksResponseCache response_cache_
 

Static Private Attributes

static const auto kSyncProtocolName = "SyncProtocol"s
 

Additional Inherited Members

- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 
- Private Member Functions inherited from NonMovable
 NonMovable (NonMovable &&)=delete
 
NonMovableoperator= (NonMovable &&)=delete
 
 NonMovable ()=default
 
 ~NonMovable ()=default
 

Detailed Description

Definition at line 101 of file sync_protocol_impl.hpp.

Constructor & Destructor Documentation

kagome::network::SyncProtocolImpl::SyncProtocolImpl ( libp2p::Host &  host,
const application::ChainSpec chain_spec,
std::shared_ptr< SyncProtocolObserver sync_observer,
std::shared_ptr< ReputationRepository reputation_repository 
)

Definition at line 127 of file sync_protocol_impl.cpp.

Member Function Documentation

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

Implements kagome::network::ProtocolBase.

Definition at line 157 of file sync_protocol_impl.cpp.

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

Implements kagome::network::ProtocolBase.

Definition at line 151 of file sync_protocol_impl.cpp.

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

Implements kagome::network::ProtocolBase.

Definition at line 116 of file sync_protocol_impl.hpp.

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

Definition at line 198 of file sync_protocol_impl.cpp.

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

Definition at line 364 of file sync_protocol_impl.cpp.

void kagome::network::SyncProtocolImpl::request ( const PeerId peer_id,
BlocksRequest  block_request,
std::function< void(outcome::result< BlocksResponse >)> &&  response_handler 
)
overridevirtual

Make async request to peer and return response in callback.

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

Implements kagome::network::SyncProtocol.

Definition at line 409 of file sync_protocol_impl.cpp.

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

Implements kagome::network::ProtocolBase.

Definition at line 143 of file sync_protocol_impl.cpp.

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

Implements kagome::network::ProtocolBase.

Definition at line 147 of file sync_protocol_impl.cpp.

void kagome::network::SyncProtocolImpl::writeRequest ( std::shared_ptr< Stream stream,
BlocksRequest  block_request,
std::function< void(outcome::result< void >)> &&  cb 
)

Definition at line 320 of file sync_protocol_impl.cpp.

void kagome::network::SyncProtocolImpl::writeResponse ( std::shared_ptr< Stream stream,
const BlocksResponse block_response 
)

Definition at line 291 of file sync_protocol_impl.cpp.

Member Data Documentation

ProtocolBaseImpl kagome::network::SyncProtocolImpl::base_
private

Definition at line 146 of file sync_protocol_impl.hpp.

const auto kagome::network::SyncProtocolImpl::kSyncProtocolName = "SyncProtocol"s
inlinestaticprivate

Definition at line 145 of file sync_protocol_impl.hpp.

std::shared_ptr<ReputationRepository> kagome::network::SyncProtocolImpl::reputation_repository_
private

Definition at line 148 of file sync_protocol_impl.hpp.

detail::BlocksResponseCache kagome::network::SyncProtocolImpl::response_cache_
private

Definition at line 149 of file sync_protocol_impl.hpp.

std::shared_ptr<SyncProtocolObserver> kagome::network::SyncProtocolImpl::sync_observer_
private

Definition at line 147 of file sync_protocol_impl.hpp.


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