TARAXA
dev::p2p Namespace Reference

Classes

class  CapabilityFace
 The Capability interface. This interface has to be implemented to support any devp2p subprotocol. More...
 
struct  NetworkStartRequired
 
struct  InvalidPublicIPAddress
 
struct  NetworkRestartNotSupported
 
struct  ECDHEError
 The ECDHE agreement failed during RLPx handshake. More...
 
struct  PeerSessionInfo
 
class  NodeIPEndpoint
 IPv4,UDP/TCP endpoints. More...
 
struct  NodeSpec
 
class  Node
 
class  EndpointTracker
 
class  ENR
 Class representing Ethereum Node Record - see EIP-778. More...
 
class  IdentitySchemeV4
 
struct  NodeInfo
 
struct  Host
 The Host class Capabilities should be registered prior to startNetwork, since m_capabilities is not thread-safe. More...
 
struct  NetworkConfig
 
class  Network
 Network Class Static network operations and interface(s). More...
 
class  NodeTableEventHandler
 
class  NodeTable
 
struct  NodeEntry
 Entry in Node Table. More...
 
struct  DiscoveryDatagram
 
struct  PingNode
 
struct  Pong
 
struct  FindNode
 
struct  Neighbours
 
struct  ENRRequest
 
struct  ENRResponse
 
class  Peer
 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...
 
class  RLPXFrameCoderImpl
 
struct  RLPXFrameInfo
 Encapsulation of Frame. More...
 
class  RLPXFrameCoder
 Encoder/decoder transport for RLPx connection established by RLPXHandshake. More...
 
struct  RLPXHandshake
 Setup inbound or outbound connection for communication over RLPXFrameCoder. RLPx Spec: https://github.com/ethereum/devp2p/blob/master/rlpx.md#encrypted-handshake. More...
 
struct  RLPXInvalidPacket
 
class  RLPXPacket
 
class  RLPXSocket
 Shared pointer wrapper for ASIO TCP socket. More...
 
struct  Session
 The Session class. More...
 
struct  TaraxaNetworkConfig
 
struct  Capability
 
struct  SessionCapability
 
class  UDPDatagram
 
struct  RLPXDatagramFace
 RLPX Datagram which can be signed. More...
 
struct  UDPSocketFace
 Interface which UDPSocket will implement. More...
 
struct  UDPSocketEvents
 Interface which a UDPSocket's owner must implement. More...
 
class  UDPSocket
 UDP Interface Handler must implement UDPSocketEvents. More...
 
class  UPnP
 

Typedefs

using NodeID = h512
 
using CapDesc = std::pair< std::string, unsigned >
 
using CapDescs = std::vector< CapDesc >
 
using PeerSessionInfos = std::vector< PeerSessionInfo >
 
using CapabilityNameAndVersion = CapDesc
 
using Capabilities = std::map< CapabilityNameAndVersion, Capability >
 
using SessionCapabilities = std::map< std::string, SessionCapability >
 

Enumerations

enum  P2pPacketType {
  HelloPacket = 0 , DisconnectPacket , PingPacket , PongPacket ,
  UserPacket = 0x10
}
 
enum  DisconnectReason {
  DisconnectRequested = 0 , TCPError , BadProtocol , UselessPeer ,
  TooManyPeers , DuplicatePeer , IncompatibleProtocol , NullIdentity ,
  ClientQuit , UnexpectedIdentity , LocalIdentity , PingTimeout ,
  UserReason = 0x10 , NoDisconnect = 0xffff
}
 
enum class  HandshakeFailureReason {
  NoFailure = 0 , UnknownFailure , Timeout , TCPError ,
  FrameDecryptionFailure , InternalError , ProtocolError , DisconnectRequested
}
 
enum class  PeerType { Optional , Required }
 
enum  NodeTableEventType { NodeEntryAdded , NodeEntryDropped , NodeEntryScheduledForEviction }
 

Functions

char const * p2pPacketTypeToString (P2pPacketType _packetType)
 
bool isPublicAddress (string const &_addressToCheck)
 
bool isPublicAddress (bi::address const &_addressToCheck)
 
bool isAllowedAddress (bool _allowLocalDiscovery, bi::address const &_addressToCheck)
 
bool isAllowedEndpoint (bool _allowLocalDiscovery, NodeIPEndpoint const &_endpointToCheck)
 
bool isPrivateAddress (bi::address const &_addressToCheck)
 
bool isPrivateAddress (string const &_addressToCheck)
 
bool isLocalHostAddress (bi::address const &_addressToCheck)
 
bool isLocalHostAddress (string const &_addressToCheck)
 
string reasonOf (DisconnectReason _r)
 
ostream & operator<< (ostream &_out, NodeIPEndpoint const &_ep)
 
bool isPrivateAddress (std::string const &_addressToCheck)
 
bool isLocalHostAddress (std::string const &_addressToCheck)
 
bool isPublicAddress (std::string const &_addressToCheck)
 
boost::log::formatting_ostream & operator<< (boost::log::formatting_ostream &_strm, Node const &_node)
 
boost::log::formatting_ostream & operator<< (boost::log::formatting_ostream &_strm, Node &_node)
 
std::ostream & operator<< (std::ostream &_strm, NodeID const &_id)
 
boost::log::formatting_ostream & operator<< (boost::log::formatting_ostream &_strm, PeerSessionInfo const &_peerSessionInfo)
 
std::ostream & operator<< (std::ostream &_out, NodeIPEndpoint const &_ep)
 Simple stream output for a NodeIPEndpoint. More...
 
std::ostream & operator<< (std::ostream &_out, ENR const &_enr)
 
 DEV_SIMPLE_EXCEPTION (ENRIsTooBig)
 
 DEV_SIMPLE_EXCEPTION (ENRSignatureIsInvalid)
 
 DEV_SIMPLE_EXCEPTION (ENRKeysAreNotUniqueSorted)
 
 DEV_SIMPLE_EXCEPTION (ENRUnknownIdentityScheme)
 
 DEV_SIMPLE_EXCEPTION (ENRSecp256k1NotFound)
 
 DEV_SIMPLE_EXCEPTION (ENRInvalidAddress)
 
bool operator== (std::weak_ptr< NodeEntry > const &_weak, std::shared_ptr< NodeEntry > const &_shared)
 
std::ostream & operator<< (std::ostream &_out, NodeTable const &_nodeTable)
 
static bytesConstRef nextRLP (bytesConstRef _b)
 

Variables

const NodeIPEndpoint UnspecifiedNodeIPEndpoint = NodeIPEndpoint{{}, 0, 0}
 
const Node UnspecifiedNode = Node{{}, UnspecifiedNodeIPEndpoint}
 
constexpr unsigned c_protocolVersion = 1029
 Peer network protocol version. More...
 
constexpr const char * c_localhostIp = "127.0.0.1"
 
constexpr unsigned short c_defaultListenPort = 30303
 

Class Documentation

◆ dev::p2p::PeerSessionInfo

struct dev::p2p::PeerSessionInfo
Collaboration diagram for dev::p2p::PeerSessionInfo:
Class Members
set< CapDesc > caps
string clientVersion
string host
NodeID id
duration lastPing
unsigned short port

◆ dev::p2p::TaraxaNetworkConfig

struct dev::p2p::TaraxaNetworkConfig
Class Members
unsigned chain_id
uint expected_parallelism
unsigned ideal_peer_count
bool is_boot_node
seconds log_active_peers_interval
milliseconds main_loop_interval
seconds peer_healthcheck_interval
seconds peer_healthcheck_timeout
unsigned peer_stretch

Typedef Documentation

◆ Capabilities

◆ CapabilityNameAndVersion

◆ CapDesc

using dev::p2p::CapDesc = typedef std::pair<std::string, unsigned>

◆ CapDescs

using dev::p2p::CapDescs = typedef std::vector<CapDesc>

◆ NodeID

using dev::p2p::NodeID = typedef h512

◆ PeerSessionInfos

using dev::p2p::PeerSessionInfos = typedef std::vector<PeerSessionInfo>

◆ SessionCapabilities

using dev::p2p::SessionCapabilities = typedef std::map<std::string, SessionCapability>

Enumeration Type Documentation

◆ DisconnectReason

Enumerator
DisconnectRequested 
TCPError 
BadProtocol 
UselessPeer 
TooManyPeers 
DuplicatePeer 
IncompatibleProtocol 
NullIdentity 
ClientQuit 
UnexpectedIdentity 
LocalIdentity 
PingTimeout 
UserReason 
NoDisconnect 

◆ HandshakeFailureReason

Enumerator
NoFailure 
UnknownFailure 
Timeout 
TCPError 
FrameDecryptionFailure 
InternalError 
ProtocolError 
DisconnectRequested 

◆ NodeTableEventType

Enumerator
NodeEntryAdded 
NodeEntryDropped 
NodeEntryScheduledForEviction 

◆ P2pPacketType

Enumerator
HelloPacket 
DisconnectPacket 
PingPacket 
PongPacket 
UserPacket 

◆ PeerType

enum dev::p2p::PeerType
strong
Enumerator
Optional 
Required 

Function Documentation

◆ DEV_SIMPLE_EXCEPTION() [1/6]

dev::p2p::DEV_SIMPLE_EXCEPTION ( ENRInvalidAddress  )

◆ DEV_SIMPLE_EXCEPTION() [2/6]

dev::p2p::DEV_SIMPLE_EXCEPTION ( ENRIsTooBig  )

◆ DEV_SIMPLE_EXCEPTION() [3/6]

dev::p2p::DEV_SIMPLE_EXCEPTION ( ENRKeysAreNotUniqueSorted  )

◆ DEV_SIMPLE_EXCEPTION() [4/6]

dev::p2p::DEV_SIMPLE_EXCEPTION ( ENRSecp256k1NotFound  )

◆ DEV_SIMPLE_EXCEPTION() [5/6]

dev::p2p::DEV_SIMPLE_EXCEPTION ( ENRSignatureIsInvalid  )

◆ DEV_SIMPLE_EXCEPTION() [6/6]

dev::p2p::DEV_SIMPLE_EXCEPTION ( ENRUnknownIdentityScheme  )

◆ isAllowedAddress()

bool dev::p2p::isAllowedAddress ( bool  _allowLocalDiscovery,
bi::address const &  _addressToCheck 
)

◆ isAllowedEndpoint()

bool dev::p2p::isAllowedEndpoint ( bool  _allowLocalDiscovery,
NodeIPEndpoint const &  _endpointToCheck 
)

◆ isLocalHostAddress() [1/3]

bool dev::p2p::isLocalHostAddress ( bi::address const &  _addressToCheck)

◆ isLocalHostAddress() [2/3]

bool dev::p2p::isLocalHostAddress ( std::string const &  _addressToCheck)

◆ isLocalHostAddress() [3/3]

bool dev::p2p::isLocalHostAddress ( string const &  _addressToCheck)

◆ isPrivateAddress() [1/3]

bool dev::p2p::isPrivateAddress ( bi::address const &  _addressToCheck)

◆ isPrivateAddress() [2/3]

bool dev::p2p::isPrivateAddress ( std::string const &  _addressToCheck)

◆ isPrivateAddress() [3/3]

bool dev::p2p::isPrivateAddress ( string const &  _addressToCheck)

◆ isPublicAddress() [1/3]

bool dev::p2p::isPublicAddress ( bi::address const &  _addressToCheck)

◆ isPublicAddress() [2/3]

bool dev::p2p::isPublicAddress ( std::string const &  _addressToCheck)

◆ isPublicAddress() [3/3]

bool dev::p2p::isPublicAddress ( string const &  _addressToCheck)

◆ nextRLP()

static bytesConstRef dev::p2p::nextRLP ( bytesConstRef  _b)
static

◆ operator<<() [1/8]

boost::log::formatting_ostream& dev::p2p::operator<< ( boost::log::formatting_ostream &  _strm,
Node _node 
)
inline

◆ operator<<() [2/8]

boost::log::formatting_ostream& dev::p2p::operator<< ( boost::log::formatting_ostream &  _strm,
Node const &  _node 
)
inline

◆ operator<<() [3/8]

boost::log::formatting_ostream& dev::p2p::operator<< ( boost::log::formatting_ostream &  _strm,
PeerSessionInfo const &  _peerSessionInfo 
)
inline

◆ operator<<() [4/8]

ostream& dev::p2p::operator<< ( ostream &  _out,
NodeIPEndpoint const &  _ep 
)

◆ operator<<() [5/8]

std::ostream & dev::p2p::operator<< ( std::ostream &  _out,
ENR const &  _enr 
)

◆ operator<<() [6/8]

std::ostream& dev::p2p::operator<< ( std::ostream &  _out,
NodeIPEndpoint const &  _ep 
)

Simple stream output for a NodeIPEndpoint.

◆ operator<<() [7/8]

std::ostream & dev::p2p::operator<< ( std::ostream &  _out,
NodeTable const &  _nodeTable 
)
inline

◆ operator<<() [8/8]

std::ostream& dev::p2p::operator<< ( std::ostream &  _strm,
NodeID const &  _id 
)
inline

◆ operator==()

bool dev::p2p::operator== ( std::weak_ptr< NodeEntry > const &  _weak,
std::shared_ptr< NodeEntry > const &  _shared 
)
inline

◆ p2pPacketTypeToString()

char const * dev::p2p::p2pPacketTypeToString ( P2pPacketType  _packetType)

◆ reasonOf()

std::string dev::p2p::reasonOf ( DisconnectReason  _r)
Returns
the string form of the given disconnection reason.

Variable Documentation

◆ c_defaultListenPort

constexpr unsigned short dev::p2p::c_defaultListenPort = 30303
constexpr

◆ c_localhostIp

constexpr const char* dev::p2p::c_localhostIp = "127.0.0.1"
constexpr

◆ c_protocolVersion

constexpr unsigned dev::p2p::c_protocolVersion = 1029
constexpr

Peer network protocol version.

◆ UnspecifiedNode

const Node dev::p2p::UnspecifiedNode = Node{{}, UnspecifiedNodeIPEndpoint}

◆ UnspecifiedNodeIPEndpoint

const NodeIPEndpoint dev::p2p::UnspecifiedNodeIPEndpoint = NodeIPEndpoint{{}, 0, 0}