[#CNode]
= CNode
:mrdocs:

Information about a peer

== Synopsis

Declared in `&lt;net&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class CNode;
----

== Member Functions

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


== Data Members

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


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:GetLocalAddrForPeer.adoc[`GetLocalAddrForPeer`]
| Returns a local address that we should advertise to this peer&period;
| xref:GetLocalAddress.adoc[`GetLocalAddress`]
| Return the best local address to use when talking to the given peer&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
