TARAXA
dev::p2p::Peer Class Reference

Representation of connectivity state and all other pertinent Peer metadata. A Peer represents connectivity between two nodes, which in this case, are the host and remote nodes. More...

#include <Peer.h>

Collaboration diagram for dev::p2p::Peer:

Public Types

using instant_t = std::chrono::system_clock::time_point
 

Public Member Functions

 Peer (Node const &_node)
 Construct Peer from Node. More...
 
 Peer (Peer const &)
 
bool shouldReconnect () const
 Return true if connection attempt should be made to this peer or false if. More...
 
bool isUseless () const
 
unsigned fallbackSeconds () const
 
- Public Member Functions inherited from dev::p2p::Node
virtual ~Node ()=default
 
 Node (Node const &)
 
 Node (Public _publicKey, NodeIPEndpoint const &_ip, PeerType _peerType=PeerType::Optional)
 
 Node (NodeSpec const &_s, PeerType _peerType=PeerType::Optional)
 
NodeID const & address () const
 
NodeIPEndpoint get_endpoint () const
 
void set_endpoint (NodeIPEndpoint endpoint)
 
 operator bool () const
 

Public Attributes

std::atomic< instant_tm_lastConnected
 Network Availability. More...
 
std::atomic< instant_tm_lastAttempted
 
std::atomic< unsigned > m_failedAttempts {0}
 
std::atomic< DisconnectReasonm_lastDisconnect = NoDisconnect
 Reason for disconnect that happened last. More...
 
std::atomic< HandshakeFailureReasonm_lastHandshakeFailure
 
- Public Attributes inherited from dev::p2p::Node
NodeID const id
 
std::atomic< PeerTypepeerType {PeerType::Optional}
 
std::atomic< uint16_t > external_udp_port
 

Detailed Description

Representation of connectivity state and all other pertinent Peer metadata. A Peer represents connectivity between two nodes, which in this case, are the host and remote nodes.

State information necessary for loading network topology is maintained by NodeTable.

Todo:

Implement 'bool required'

reputation: Move score, rating to capability-specific map (&& remove friend class)

reputation: implement via origin-tagged events

Populate metadata upon construction; save when destroyed.

Metadata for peers needs to be handled via a storage backend. Specifically, peers can be utilized in a variety of many-to-many relationships while also needing to modify shared instances of those peers. Modifying these properties via a storage backend alleviates Host of the responsibility. (&& remove save/restoreNetwork)

reimplement recording of historical session information on per-transport basis

move attributes into protected

Member Typedef Documentation

◆ instant_t

using dev::p2p::Peer::instant_t = std::chrono::system_clock::time_point

Constructor & Destructor Documentation

◆ Peer() [1/2]

dev::p2p::Peer::Peer ( Node const &  _node)
inline

Construct Peer from Node.

◆ Peer() [2/2]

dev::p2p::Peer::Peer ( Peer const &  _original)

Member Function Documentation

◆ fallbackSeconds()

unsigned dev::p2p::Peer::fallbackSeconds ( ) const

Returns number of seconds to wait until attempting connection, based on attempted connection history

◆ isUseless()

bool dev::p2p::Peer::isUseless ( ) const

A peer which should never be reconnected to - e.g. it's running on a different network, we don't have any common capabilities

◆ shouldReconnect()

bool dev::p2p::Peer::shouldReconnect ( ) const

Return true if connection attempt should be made to this peer or false if.

Member Data Documentation

◆ m_failedAttempts

std::atomic<unsigned> dev::p2p::Peer::m_failedAttempts {0}

◆ m_lastAttempted

std::atomic<instant_t> dev::p2p::Peer::m_lastAttempted

◆ m_lastConnected

std::atomic<instant_t> dev::p2p::Peer::m_lastConnected

Network Availability.

◆ m_lastDisconnect

std::atomic<DisconnectReason> dev::p2p::Peer::m_lastDisconnect = NoDisconnect

Reason for disconnect that happened last.

◆ m_lastHandshakeFailure

std::atomic<HandshakeFailureReason> dev::p2p::Peer::m_lastHandshakeFailure
Initial value:

Reason for most recent handshake failure


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