|
TARAXA
|
The Host class Capabilities should be registered prior to startNetwork, since m_capabilities is not thread-safe. More...
#include <Host.h>

Classes | |
| struct | KnownNode |
| struct | PersistentState |
| Deserialise the data and populate the set of known peers. More... | |
Public Types | |
| using | CapabilityList = std::vector< std::shared_ptr< CapabilityFace > > |
| using | CapabilitiesFactory = std::function< CapabilityList(std::weak_ptr< Host >)> |
Public Member Functions | |
| Capabilities | getSupportedCapabilities () |
| ~Host () | |
| ba::io_context::count_type | do_work () |
| ba::io_context::count_type | do_discov () |
| bool | isRunning () |
| uint64_t | peer_count () const |
| unsigned short | listenPort () const |
| Get the port we're listening on currently. | |
| NodeID | id () const |
| Get our current node ID. | |
| auto | getNodeCount () const |
| std::list< NodeEntry > | getNodes () const |
| void | addNode (Node const &_node) |
| void | invalidateNode (NodeID const &_node) |
| void | disconnect (NodeID const &_nodeID, DisconnectReason _reason) |
| void | send (NodeID const &node_id, std::string capability_name, unsigned packet_type, bytes payload, std::function< void()> &&on_done={}) |
| std::string | enode () const |
| Get the endpoint information. | |
| bool | nodeTableHasNode (Public const &_id) const |
Static Public Member Functions | |
| static std::shared_ptr< Host > | make (std::string _clientVersion, CapabilitiesFactory const &cap_factory, KeyPair const &kp, NetworkConfig _n, TaraxaNetworkConfig taraxa_conf={}, std::filesystem::path state_file_path={}) |
Private Types | |
| enum | PeerSlotType { Egress , Ingress } |
Private Attributes | |
| std::atomic< bool > | fully_initialized_ = false |
| ba::io_context | ioc_ |
| ba::executor_work_guard< ba::io_context::executor_type > | ioc_w_ |
| ba::io_context | session_ioc_ |
| ba::executor_work_guard< ba::io_context::executor_type > | session_ioc_w_ |
| ba::io_context::strand | strand_ |
| bi::tcp::acceptor | m_tcp4Acceptor |
| ba::steady_timer | m_runTimer |
| std::filesystem::path | state_file_path_ |
| std::string | m_clientVersion |
| Our version string. | |
| NetworkConfig | m_netConfig |
| Network settings. | |
| TaraxaNetworkConfig | taraxa_conf_ |
| unsigned | m_idealPeerCount = 0 |
| Ideal number of peers to be connected to. | |
| unsigned | m_stretchPeers = 0 |
| Capabilities | m_capabilities |
| Each of the capabilities we support. | |
| unsigned | m_listenPort |
| bi::tcp::endpoint | m_tcpPublic |
| KeyPair | m_alias |
| Alias for network communication. | |
| std::shared_ptr< RLPXHandshake::HostContext > | handshake_ctx_ |
| std::set< Peer * > | m_pendingPeerConns |
| std::unordered_map< NodeID, std::shared_ptr< Peer > > | m_peers |
| std::unordered_map< NodeID, std::weak_ptr< Session > > | m_sessions |
| std::list< std::weak_ptr< RLPXHandshake > > | m_connecting |
| std::chrono::steady_clock::time_point | m_lastPing |
| Time we sent the last ping to all peers. | |
| std::chrono::steady_clock::time_point | m_lastPeerLogMessage |
| std::unique_ptr< NodeTable > | m_nodeTable |
| Node table (uses kademlia-like discovery). | |
| std::atomic< uint64_t > | peer_count_snapshot_ = 0 |
| Logger | m_logger {createLogger(VerbosityDebug, "net")} |
| Logger | m_detailsLogger {createLogger(VerbosityTrace, "net")} |
| Logger | m_infoLogger {createLogger(VerbosityInfo, "net")} |
The Host class Capabilities should be registered prior to startNetwork, since m_capabilities is not thread-safe.
determinePublic: ipv6, udp
per-session keepalive/ping instead of broadcast; set ping-timeout via median-latency
| struct dev::p2p::Host::KnownNode |
| struct dev::p2p::Host::PersistentState |
| using dev::p2p::Host::CapabilitiesFactory = std::function<CapabilityList(std::weak_ptr<Host>)> |
| using dev::p2p::Host::CapabilityList = std::vector<std::shared_ptr<CapabilityFace> > |
|
private |
|
private |
!! this needs to be post to session_ioc_ as main_loop_body handles peer/session related stuff
| Host::~Host | ( | ) |
|
private |
Determines publicly advertised address.
|
inline |
| ba::io_context::count_type Host::do_discov | ( | ) |
| ba::io_context::count_type Host::do_work | ( | ) |
|
inline |
Get the endpoint information.
|
inline |
|
inline |
|
inline |
|
inline |
Get our current node ID.
|
inlineprivate |
Determines if a node with the supplied endpoint should be included in or restored from the serialized network configuration data
|
inline |
|
private |
Ping the peers to update the latency information and disconnect peers which have timed out.
|
inlineprivate |
Get the address we're listening on currently.
Get the port we're listening on currently.
|
private |
Log count of active peers and information about each peer.
|
private |
|
static |
|
inlineprivate |
|
inlineprivate |
Get the node information.
|
private |
|
inline |
|
private |
Get number of peers connected.
|
private |
Get session by id.
|
private |
Get peer information.
|
inlineprivate |
|
private |
Returns true if pending and connected peer count is less than maximum.
|
private |
|
private |
Get or create host's Ethereum Node record.
|
private |
|
private |
Serialise the set of known peers.
|
inline |
|
private |
Validates and starts peer session, taking ownership of _io. Disconnects and returns false upon error.
|
inlineprivate |
Get the public TCP endpoint.
|
private |
|
private |
|
private |
|
private |
|
private |
Alias for network communication.
|
private |
Each of the capabilities we support.
|
private |
Our version string.
|
private |
Pending connections. Completed handshakes are garbage-collected in run() (a handshake is complete when there are no more shared_ptrs in handlers)
|
private |
|
private |
Ideal number of peers to be connected to.
|
private |
|
private |
When the last "active peers" message was logged - used to throttle logging to once every c_logActivePeersInterval seconds
|
private |
Time we sent the last ping to all peers.
|
private |
|
mutableprivate |
|
private |
Network settings.
|
private |
Node table (uses kademlia-like discovery).
|
private |
The nodes to which we are currently connected. Used by host to service peer requests and keepAlivePeers and for shutdown. (see run()) Mutable because we flush zombie entries (null-weakptrs) as regular maintenance from a const method.
|
private |
|
private |
Accepted connection multiplier (max peers = ideal*stretch).
|
private |
|
private |
Our public listening endpoint.
|
private |
|
private |
|
private |
|
private |
|
private |
Listening acceptor. Timer which, when network is running, calls run() every c_timerInterval ms.
|
private |