Kagome
Polkadot Runtime Engine in C++17
kagome::network::PeerManager Class Referenceabstract

#include <peer_manager.hpp>

Inheritance diagram for kagome::network::PeerManager:
Collaboration diagram for kagome::network::PeerManager:

Public Types

using PeerId = libp2p::peer::PeerId
 
using PeerInfo = libp2p::peer::PeerInfo
 
using BlockInfo = primitives::BlockInfo
 
using AdvResult = outcome::result< std::pair< network::CollatorPublicKey const &, network::ParachainId >>
 

Public Member Functions

virtual ~PeerManager ()=default
 
virtual void connectToPeer (const PeerInfo &peer_info)=0
 
virtual void reserveStreams (const PeerId &peer_id) const =0
 
virtual std::shared_ptr< StreamEnginegetStreamEngine ()=0
 
virtual void keepAlive (const PeerId &peer_id)=0
 
virtual void startPingingPeer (const PeerId &peer_id)=0
 
virtual void updatePeerState (const PeerId &peer_id, const Status &status)=0
 
virtual void updatePeerState (const PeerId &peer_id, const BlockAnnounce &announce)=0
 
virtual outcome::result< std::pair< network::CollatorPublicKey const &, network::ParachainId > > insert_advertisement (PeerState &peer_state, ParachainState &parachain_state, primitives::BlockHash para_hash)=0
 
virtual ParachainStateparachainState ()=0
 
virtual void setCollating (const PeerId &peer_id, network::CollatorPublicKey const &collator_id, network::ParachainId para_id)=0
 
virtual void updatePeerState (const PeerId &peer_id, const GrandpaNeighborMessage &neighbor_message)=0
 
virtual std::optional< std::reference_wrapper< PeerState > > getPeerState (const PeerId &peer_id)=0
 
virtual size_t activePeersNumber () const =0
 
virtual void forEachPeer (std::function< void(const PeerId &)> func) const =0
 
virtual void forOnePeer (const PeerId &peer_id, std::function< void(const PeerId &)> func) const =0
 

Detailed Description

Manage active peers:

  • peer discovery (internally)
  • provides needed amount of active peers
  • connects to specified peer by their id
  • apply some func for active peer(s)

Definition at line 63 of file peer_manager.hpp.

Member Typedef Documentation

Definition at line 69 of file peer_manager.hpp.

using kagome::network::PeerManager::PeerId = libp2p::peer::PeerId

Definition at line 65 of file peer_manager.hpp.

using kagome::network::PeerManager::PeerInfo = libp2p::peer::PeerInfo

Definition at line 66 of file peer_manager.hpp.

Constructor & Destructor Documentation

virtual kagome::network::PeerManager::~PeerManager ( )
virtualdefault

Member Function Documentation

virtual size_t kagome::network::PeerManager::activePeersNumber ( ) const
pure virtual
Returns
number of active peers

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::connectToPeer ( const PeerInfo peer_info)
pure virtual

Force connect to peer by {

Parameters
peer_info}

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::forEachPeer ( std::function< void(const PeerId &)>  func) const
pure virtual

Apply {

Parameters
func}to each active peer

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::forOnePeer ( const PeerId peer_id,
std::function< void(const PeerId &)>  func 
) const
pure virtual

Apply {

Parameters
func}to an active peer with id {
peer_id}

Implemented in kagome::network::PeerManagerImpl.

virtual std::optional<std::reference_wrapper<PeerState> > kagome::network::PeerManager::getPeerState ( const PeerId peer_id)
pure virtual
Returns
known info about peer with {
Parameters
peer_id}or none

Implemented in kagome::network::PeerManagerImpl.

virtual std::shared_ptr<StreamEngine> kagome::network::PeerManager::getStreamEngine ( )
pure virtual

Return stream engine object.

Implemented in kagome::network::PeerManagerImpl.

virtual outcome::result< std::pair<network::CollatorPublicKey const &, network::ParachainId> > kagome::network::PeerManager::insert_advertisement ( PeerState peer_state,
ParachainState parachain_state,
primitives::BlockHash  para_hash 
)
pure virtual

Store advertisement from a peer to later processing;

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::keepAlive ( const PeerId peer_id)
pure virtual

Keeps peer with {

Parameters
peer_id}alive

Implemented in kagome::network::PeerManagerImpl.

virtual ParachainState& kagome::network::PeerManager::parachainState ( )
pure virtual

Allows to update parachains states.

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::reserveStreams ( const PeerId peer_id) const
pure virtual

Reserves stream slots of needed protocols for peer by {

Parameters
peer_id}

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::setCollating ( const PeerId peer_id,
network::CollatorPublicKey const &  collator_id,
network::ParachainId  para_id 
)
pure virtual

Updates collation state and stores parachain id. Should be called once for each peer per connection. If else -> reduce reputation.

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::startPingingPeer ( const PeerId peer_id)
pure virtual

Starts outgoing pinging to peer with {

Parameters
peer_id}

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::updatePeerState ( const PeerId peer_id,
const Status status 
)
pure virtual

Updates known data about peer with {

Parameters
peer_id}by {
status}

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::updatePeerState ( const PeerId peer_id,
const BlockAnnounce announce 
)
pure virtual

Updates known data about peer with {

Parameters
peer_id}by {
announce}

Implemented in kagome::network::PeerManagerImpl.

virtual void kagome::network::PeerManager::updatePeerState ( const PeerId peer_id,
const GrandpaNeighborMessage neighbor_message 
)
pure virtual

Updates known data about peer with {

Parameters
peer_id}by {
neighbor_message}

Implemented in kagome::network::PeerManagerImpl.


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