Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
dev::p2p::Peer Class Reference

Representation of connectivity state and all other pertinent Peer metadata. More...

#include <Peer.h>

Inheritance diagram for dev::p2p::Peer:
[legend]
Collaboration diagram for dev::p2p::Peer:
[legend]

Public Member Functions

 Peer (Node const &_node)
 Construct Peer from Node. More...
 
bool isOffline () const
 
virtual bool operator< (Peer const &_p) const
 
int rating () const
 WIP: Returns current peer rating. More...
 
bool shouldReconnect () const
 Return true if connection attempt should be made to this peer or false if. More...
 
int failedAttempts () const
 Number of times connection has been attempted to peer. More...
 
DisconnectReason lastDisconnect () const
 Reason peer was previously disconnected. More...
 
void noteSessionGood ()
 Peer session is noted as useful. More...
 
- Public Member Functions inherited from dev::p2p::Node
 Node ()=default
 
 Node (Node const &)=default
 
 Node (Public _publicKey, NodeIPEndpoint const &_ip, PeerType _peerType=PeerType::Optional)
 
 Node (NodeSpec const &_s, PeerType _peerType=PeerType::Optional)
 
virtual NodeID const & address () const
 
virtual Public const & publicKey () const
 
virtual operator bool () const
 

Protected Member Functions

unsigned fallbackSeconds () const
 Returns number of seconds to wait until attempting connection, based on attempted connection history. More...
 

Protected Attributes

int m_score = 0
 All time cumulative. More...
 
int m_rating = 0
 Trending. More...
 
std::chrono::system_clock::time_point m_lastConnected
 Network Availability. More...
 
std::chrono::system_clock::time_point m_lastAttempted
 
unsigned m_failedAttempts = 0
 
DisconnectReason m_lastDisconnect = NoDisconnect
 Reason for disconnect that happened last. More...
 
std::weak_ptr< Sessionm_session
 Used by isOffline() and (todo) for peer to emit session information. More...
 

Friends

class Session
 
class Host
 Allows Session to update score and rating. More...
 
class RLPXHandshake
 For Host: saveNetwork(), restoreNetwork() More...
 

Additional Inherited Members

- Public Attributes inherited from dev::p2p::Node
NodeID id
 
NodeIPEndpoint endpoint
 Endpoints by which we expect to reach node. More...
 
PeerType peerType = PeerType::Optional
 

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

Definition at line 52 of file Peer.h.

Constructor & Destructor Documentation

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

Construct Peer from Node.

Definition at line 61 of file Peer.h.

Member Function Documentation

int dev::p2p::Peer::failedAttempts ( ) const
inline

Number of times connection has been attempted to peer.

Definition at line 74 of file Peer.h.

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

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

Definition at line 39 of file Peer.cpp.

Here is the caller graph for this function:

bool dev::p2p::Peer::isOffline ( ) const
inline

Definition at line 63 of file Peer.h.

Here is the call graph for this function:

Here is the caller graph for this function:

DisconnectReason dev::p2p::Peer::lastDisconnect ( ) const
inline

Reason peer was previously disconnected.

Definition at line 77 of file Peer.h.

void dev::p2p::Peer::noteSessionGood ( )
inline

Peer session is noted as useful.

Definition at line 80 of file Peer.h.

Here is the call graph for this function:

bool dev::p2p::Peer::operator< ( Peer const &  _p) const
virtual

Definition at line 63 of file Peer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int dev::p2p::Peer::rating ( ) const
inline

WIP: Returns current peer rating.

Definition at line 68 of file Peer.h.

Here is the call graph for this function:

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

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

Definition at line 34 of file Peer.cpp.

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class Host
friend

Allows Session to update score and rating.

Definition at line 55 of file Peer.h.

friend class RLPXHandshake
friend

For Host: saveNetwork(), restoreNetwork()

Definition at line 57 of file Peer.h.

friend class Session
friend

Definition at line 54 of file Peer.h.

Member Data Documentation

unsigned dev::p2p::Peer::m_failedAttempts = 0
protected

Definition at line 93 of file Peer.h.

std::chrono::system_clock::time_point dev::p2p::Peer::m_lastAttempted
protected

Definition at line 92 of file Peer.h.

std::chrono::system_clock::time_point dev::p2p::Peer::m_lastConnected
protected

Network Availability.

Definition at line 91 of file Peer.h.

DisconnectReason dev::p2p::Peer::m_lastDisconnect = NoDisconnect
protected

Reason for disconnect that happened last.

Definition at line 94 of file Peer.h.

int dev::p2p::Peer::m_rating = 0
protected

Trending.

Definition at line 87 of file Peer.h.

int dev::p2p::Peer::m_score = 0
protected

All time cumulative.

Definition at line 86 of file Peer.h.

std::weak_ptr<Session> dev::p2p::Peer::m_session
protected

Used by isOffline() and (todo) for peer to emit session information.

Definition at line 97 of file Peer.h.


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