CNode

Information about a peer

Synopsis

Declared in <net.h>

class CNode;

Member Functions

NameDescription
CNode [constructor]Constructors
operator= [deleted]Deleted copy assignment; nodes are non-copyable.
AccountForSentBytes Account for the total size of a sent message in the per msg type connection stats.
AddRef Increment the reference count and return this node.
AdvertisedVersion Protocol version advertised in our VERSION message. Private broadcast connections use a fixed version to maximise anonymity.
CloseSocketDisconnect Close the socket and mark the connection as disconnected.
ConnectedThroughNetwork Get network the peer connected through.
ConnectionTypeAsString Return the connection type as a human-readable string.
CopyStats Copy this node's current statistics into the given CNodeStats.
DisconnectMsg Helper function to log disconnects.
ExpectServicesFromConn Whether we expect the peer to offer the services we want, given the connection type.
GetAddrLocal Return our local address as reported by this peer.
GetCommonVersion Return the greatest protocol version common to us and the peer.
GetId Return this peer's unique identifier.
GetLocalNonce Return the local nonce used to detect connections to ourselves.
GetRefCount Return the current outstanding reference count for this node.
HasPermission Return whether this peer has been granted the given permission flag.
IsAddrFetchConn Whether this is an address-fetch connection.
IsBlockOnlyConn Whether this is a block-relay-only connection.
IsConnectedThroughPrivacyNet Whether this peer connected through a privacy network.
IsFeelerConn Whether this is a feeler connection.
IsFullOutboundConn Whether this is an outbound full-relay connection.
IsInboundConn Whether this is an inbound connection.
IsManualConn Whether this is a manually added connection.
IsManualOrFullOutboundConn Whether this is a manual or outbound full-relay connection.
IsOutboundOrBlockRelayConn Whether this is an outbound full-relay or block-relay-only connection.
IsPrivateBroadcastConn Whether this is a private broadcast connection.
LogPeer Helper function to log the peer id, optionally including IP address.
MarkReceivedMsgsForProcessing Move all messages from the received queue to the processing queue.
PollMessage Poll the next message from the processing queue of this connection.
PongReceived A ping-pong round trip has completed successfully. Update latest and minimum ping durations.
ReceiveMsgBytes Receive bytes from the buffer and deserialize them into messages.
Release Decrement the reference count.
SetAddrLocal May not be called more than once
SetCommonVersion Record the greatest protocol version common to us and the peer.

Data Members

NameDescription
addr Address of this peer.
addrBind Bind address of our side of the connection.
cleanSubVer cleanSubVer is a sanitized string of the user agent byte array we read from the wire. This cleaned string can safely be logged or displayed.
cs_vRecv Guards the receive-side state.
cs_vSend Guards the send-side state (vSendMsg, nSendBytes, etc.).
fDisconnect Setting this to true causes the node to be disconnected the next time DisconnectNodes() runs.
fPauseRecv Whether receiving from this peer is currently paused (receive buffer full).
fPauseSend Whether sending to this peer is currently paused (send buffer full).
fSuccessfullyConnected fSuccessfullyConnected is set to true on receiving VERACK from the peer.
grantOutbound Outbound connection slot grant held for the lifetime of the connection.
m_addr_name Human-readable address or hostname of the peer.
m_bip152_highbandwidth_from The peer selected us as a (compact blocks) high-bandwidth peer (BIP152).
m_bip152_highbandwidth_to We selected this peer as a (compact blocks) high-bandwidth peer (BIP152).
m_bloom_filter_loaded Whether this peer has loaded a bloom filter. Used only in inbound eviction logic.
m_conn_type Type of this connection (inbound, outbound full relay, etc.).
m_connected Unix epoch time at peer connection
m_dest The pszDest argument provided to ConnectNode(). Only used for reconnections.
m_has_all_wanted_services Whether this peer provides all services that we want. Used for eviction decisions
m_inbound_onion Whether this peer is an inbound onion, i.e. connected via our Tor onion service.
m_last_block_time UNIX epoch time of the last block received from this peer that we had not yet seen (e.g. not already received from another peer), that passed preliminary validity checks and was saved to disk, even if we don't connect the block or it eventually fails to connect. Used as an inbound peer eviction criterion in CConnman::AttemptToEvictConnection.
m_last_ping_time Last measured round-trip duration. Used only for stats.
m_last_recv Time of the last receive from this peer.
m_last_send Time of the last send to this peer.
m_last_tx_time UNIX epoch time of the last transaction received from this peer that we had not yet seen (e.g. not already received from another peer) and that was accepted into our mempool. Used as an inbound peer eviction criterion in CConnman::AttemptToEvictConnection.
m_min_ping_time Lowest measured round-trip duration. Used as an inbound peer eviction criterion in CConnman::AttemptToEvictConnection.
m_network_key Network key used to prevent fingerprinting our node across networks. Influenced by the network and the bind address (+ bind port for inbounds)
m_permission_flags Permission flags granted to this peer.
m_prefer_evict This peer is preferred for eviction.
m_proxy_override Proxy to use regardless of global proxy settings if reconnecting to this node.
m_relays_txs Whether we should relay transactions to this peer. This only changes from false to true. It will never change back to false.
m_send_memusage Sum of GetMemoryUsage of all vSendMsg entries.
m_sock Socket used for communication with the node. May not own a Sock object (after CloseSocketDisconnect() or during tests). shared_ptr (instead of unique_ptr) is used to avoid premature close of the underlying file descriptor by one thread while another thread is poll(2)-ing it for activity.
m_sock_mutex Guards access to m_sock and m_i2p_sam_session.
m_subver_mutex Guards cleanSubVer.
m_transport Transport serializer/deserializer. The receive side functions are only called under cs_vRecv, while the sending side functions are only called under cs_vSend.
nKeyedNetGroup Network group key used to bucket this peer for eviction and diversity.
nRecvBytes Total number of bytes received on the wire from this peer.
nRefCount Number of outstanding references to this node.
nSendBytes Total number of bytes sent on the wire to this peer.
nVersion Protocol version advertised by the peer (0 until received).
vSendMsg Messages still to be fed to m_transport->SetMessageToSend.

Non-Member Functions

NameDescription
GetLocalAddrForPeerReturns a local address that we should advertise to this peer.
GetLocalAddressReturn the best local address to use when talking to the given peer.