Information about a peer.
More...
#include <net.h>
|
| std::shared_ptr< Sock > m_sock | GUARDED_BY (m_sock_mutex) |
| | Socket used for communication with the node. More...
|
| |
| size_t nSendSize | GUARDED_BY (cs_vSend) |
| | Total size of all vSendMsg entries. More...
|
| |
| size_t nSendOffset | GUARDED_BY (cs_vSend) |
| | Offset inside the first vSendMsg already sent. More...
|
| |
| uint64_t nSendBytes | GUARDED_BY (cs_vSend) |
| |
| std::deque< std::vector< unsigned char > > vSendMsg | GUARDED_BY (cs_vSend) |
| |
| std::list< CNetMessage > vProcessMsg | GUARDED_BY (cs_vProcessMsg) |
| |
| size_t nProcessQueueSize | GUARDED_BY (cs_vProcessMsg) |
| |
| uint64_t nRecvBytes | GUARDED_BY (cs_vRecv) |
| |
| std::string cleanSubVer | GUARDED_BY (m_subver_mutex) |
| | cleanSubVer is a sanitized string of the user agent byte array we read from the wire. More...
|
| |
| bool | HasPermission (NetPermissionFlags permission) const |
| |
| bool | IsOutboundOrBlockRelayConn () const |
| |
| bool | IsFullOutboundConn () const |
| |
| bool | IsManualConn () const |
| |
| bool | IsBlockOnlyConn () const |
| |
| bool | IsFeelerConn () const |
| |
| bool | IsAddrFetchConn () const |
| |
| bool | IsInboundConn () const |
| |
| bool | ExpectServicesFromConn () const |
| |
| Network | ConnectedThroughNetwork () const |
| | Get network the peer connected through. More...
|
| |
| | CNode (NodeId id, std::shared_ptr< Sock > sock, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress &addrBindIn, const std::string &addrNameIn, ConnectionType conn_type_in, bool inbound_onion, CNodeOptions &&node_opts={}) |
| |
| | CNode (const CNode &)=delete |
| |
| CNode & | operator= (const CNode &)=delete |
| |
| NodeId | GetId () const |
| |
| uint64_t | GetLocalNonce () const |
| |
| int | GetRefCount () const |
| |
| bool | ReceiveMsgBytes (Span< const uint8_t > msg_bytes, bool &complete) EXCLUSIVE_LOCKS_REQUIRED(!cs_vRecv) |
| | Receive bytes from the buffer and deserialize them into messages. More...
|
| |
| void | SetCommonVersion (int greatest_common_version) |
| |
| int | GetCommonVersion () const |
| |
| CService | GetAddrLocal () const EXCLUSIVE_LOCKS_REQUIRED(!m_addr_local_mutex) |
| |
| void | SetAddrLocal (const CService &addrLocalIn) EXCLUSIVE_LOCKS_REQUIRED(!m_addr_local_mutex) |
| | May not be called more than once. More...
|
| |
| CNode * | AddRef () |
| |
| void | Release () |
| |
| void | CloseSocketDisconnect () EXCLUSIVE_LOCKS_REQUIRED(!m_sock_mutex) |
| |
| void | CopyStats (CNodeStats &stats) EXCLUSIVE_LOCKS_REQUIRED(!m_subver_mutex |
| |
| std::string | ConnectionTypeAsString () const |
| |
| void | PongReceived (std::chrono::microseconds ping_time) |
| | A ping-pong round trip has completed successfully. More...
|
| |
Information about a peer.
Definition at line 347 of file net.h.
◆ CNode() [1/2]
| CNode::CNode |
( |
NodeId |
id, |
|
|
std::shared_ptr< Sock > |
sock, |
|
|
const CAddress & |
addrIn, |
|
|
uint64_t |
nKeyedNetGroupIn, |
|
|
uint64_t |
nLocalHostNonceIn, |
|
|
const CAddress & |
addrBindIn, |
|
|
const std::string & |
addrNameIn, |
|
|
ConnectionType |
conn_type_in, |
|
|
bool |
inbound_onion, |
|
|
CNodeOptions && |
node_opts = {} |
|
) |
| |
◆ CNode() [2/2]
| CNode::CNode |
( |
const CNode & |
| ) |
|
|
delete |
◆ AddRef()
◆ CloseSocketDisconnect()
| void CNode::CloseSocketDisconnect |
( |
| ) |
|
◆ ConnectedThroughNetwork()
| Network CNode::ConnectedThroughNetwork |
( |
| ) |
const |
Get network the peer connected through.
Returns Network::NET_ONION for inbound onion connections, and CNetAddr::GetNetClass() otherwise. The latter cannot be used directly because it doesn't detect the former, and it's not the responsibility of the CNetAddr class to know the actual network a peer is connected through.
- Returns
- network the peer connected through.
Definition at line 618 of file net.cpp.
◆ ConnectionTypeAsString()
| std::string CNode::ConnectionTypeAsString |
( |
| ) |
const |
|
inline |
◆ CopyStats()
◆ ExpectServicesFromConn()
| bool CNode::ExpectServicesFromConn |
( |
| ) |
const |
|
inline |
◆ GetAddrLocal()
◆ GetCommonVersion()
| int CNode::GetCommonVersion |
( |
| ) |
const |
|
inline |
◆ GetId()
◆ GetLocalNonce()
| uint64_t CNode::GetLocalNonce |
( |
| ) |
const |
|
inline |
◆ GetRefCount()
| int CNode::GetRefCount |
( |
| ) |
const |
|
inline |
◆ GUARDED_BY() [1/13]
◆ GUARDED_BY() [2/13]
| size_t nSendSize CNode::GUARDED_BY |
( |
cs_vSend |
| ) |
|
|
inline |
Total size of all vSendMsg entries.
Definition at line 369 of file net.h.
◆ GUARDED_BY() [3/13]
| size_t nSendOffset CNode::GUARDED_BY |
( |
cs_vSend |
| ) |
|
|
inline |
Offset inside the first vSendMsg already sent.
Definition at line 371 of file net.h.
◆ GUARDED_BY() [4/13]
| uint64_t nSendBytes CNode::GUARDED_BY |
( |
cs_vSend |
| ) |
|
|
inline |
◆ GUARDED_BY() [5/13]
| std::deque<std::vector<unsigned char> > vSendMsg CNode::GUARDED_BY |
( |
cs_vSend |
| ) |
|
◆ GUARDED_BY() [6/13]
◆ GUARDED_BY() [7/13]
◆ GUARDED_BY() [8/13]
| uint64_t nRecvBytes CNode::GUARDED_BY |
( |
cs_vRecv |
| ) |
|
|
inline |
◆ GUARDED_BY() [9/13]
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.
Definition at line 404 of file net.h.
◆ GUARDED_BY() [10/13]
◆ GUARDED_BY() [11/13]
◆ GUARDED_BY() [12/13]
◆ GUARDED_BY() [13/13]
If an I2P session is created per connection (for outbound transient I2P connections) then it is stored here so that it can be destroyed when the socket is closed.
I2P sessions involve a data/transport socket (in m_sock) and a control socket (in m_i2p_sam_session). For transient sessions, once the data socket is closed, the control socket is not going to be used anymore and is just taking up resources. So better close it as soon as m_sock is closed. Otherwise this unique_ptr is empty.
◆ HasPermission()
◆ IsAddrFetchConn()
| bool CNode::IsAddrFetchConn |
( |
| ) |
const |
|
inline |
◆ IsBlockOnlyConn()
| bool CNode::IsBlockOnlyConn |
( |
| ) |
const |
|
inline |
◆ IsFeelerConn()
| bool CNode::IsFeelerConn |
( |
| ) |
const |
|
inline |
◆ IsFullOutboundConn()
| bool CNode::IsFullOutboundConn |
( |
| ) |
const |
|
inline |
◆ IsInboundConn()
| bool CNode::IsInboundConn |
( |
| ) |
const |
|
inline |
◆ IsManualConn()
| bool CNode::IsManualConn |
( |
| ) |
const |
|
inline |
◆ IsOutboundOrBlockRelayConn()
| bool CNode::IsOutboundOrBlockRelayConn |
( |
| ) |
const |
|
inline |
◆ operator=()
◆ PongReceived()
| void CNode::PongReceived |
( |
std::chrono::microseconds |
ping_time | ) |
|
|
inline |
A ping-pong round trip has completed successfully.
Update latest and minimum ping times.
Definition at line 595 of file net.h.
◆ ReceiveMsgBytes()
| bool CNode::ReceiveMsgBytes |
( |
Span< const uint8_t > |
msg_bytes, |
|
|
bool & |
complete |
|
) |
| |
Receive bytes from the buffer and deserialize them into messages.
- Parameters
-
| [in] | msg_bytes | The raw data |
| [out] | complete | Set True if at least one message has been deserialized and is ready to be processed |
- Returns
- True if the peer should stay connected, False if the peer should be disconnected from.
Definition at line 669 of file net.cpp.
◆ Release()
◆ SetAddrLocal()
| void CNode::SetAddrLocal |
( |
const CService & |
addrLocalIn | ) |
|
May not be called more than once.
Definition at line 608 of file net.cpp.
◆ SetCommonVersion()
| void CNode::SetCommonVersion |
( |
int |
greatest_common_version | ) |
|
|
inline |
◆ CConnman
◆ ConnmanTestMsg
◆ !cs_vRecv
◆ !cs_vSend
◆ !m_addr_local_mutex
| void CNode::!m_addr_local_mutex |
◆ addr
◆ addrBind
◆ cs_sendProcessing
◆ cs_vProcessMsg
◆ cs_vRecv
◆ cs_vSend
◆ fDisconnect
| std::atomic_bool CNode::fDisconnect {false} |
◆ fPauseRecv
| std::atomic_bool CNode::fPauseRecv {false} |
◆ fPauseSend
| std::atomic_bool CNode::fPauseSend {false} |
◆ fSuccessfullyConnected
| std::atomic_bool CNode::fSuccessfullyConnected {false} |
fSuccessfullyConnected is set to true on receiving VERACK from the peer.
Definition at line 410 of file net.h.
◆ grantOutbound
◆ id
◆ m_addr_local_mutex
| Mutex CNode::m_addr_local_mutex |
|
mutableprivate |
◆ m_addr_name
| const std::string CNode::m_addr_name |
◆ m_bip152_highbandwidth_from
| std::atomic<bool> CNode::m_bip152_highbandwidth_from {false} |
◆ m_bip152_highbandwidth_to
| std::atomic<bool> CNode::m_bip152_highbandwidth_to {false} |
◆ m_bloom_filter_loaded
| std::atomic_bool CNode::m_bloom_filter_loaded {false} |
Whether this peer has loaded a bloom filter.
Used only in inbound eviction logic.
Definition at line 503 of file net.h.
◆ m_conn_type
◆ m_connected
| const std::chrono::seconds CNode::m_connected |
Unix epoch time at peer connection.
Definition at line 389 of file net.h.
◆ m_deserializer
◆ m_greatest_common_version
◆ m_has_all_wanted_services
| std::atomic_bool CNode::m_has_all_wanted_services {false} |
Whether this peer provides all services that we want.
Used for eviction decisions
Definition at line 493 of file net.h.
◆ m_inbound_onion
| const bool CNode::m_inbound_onion |
Whether this peer is an inbound onion, i.e. connected via our Tor onion service.
Definition at line 397 of file net.h.
◆ m_last_block_time
| std::atomic<std::chrono::seconds> CNode::m_last_block_time {0s} |
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 connection. Used as an inbound peer eviction criterium in CConnman::AttemptToEvictConnection.
Definition at line 510 of file net.h.
◆ m_last_ping_time
| std::atomic<std::chrono::microseconds> CNode::m_last_ping_time {0us} |
Last measured round-trip time.
Used only for RPC/GUI stats/debugging.
Definition at line 519 of file net.h.
◆ m_last_recv
| std::atomic<std::chrono::seconds> CNode::m_last_recv {0s} |
◆ m_last_send
| std::atomic<std::chrono::seconds> CNode::m_last_send {0s} |
◆ m_last_tx_time
| std::atomic<std::chrono::seconds> CNode::m_last_tx_time {0s} |
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 criterium in CConnman::AttemptToEvictConnection.
Definition at line 516 of file net.h.
◆ m_min_ping_time
| std::atomic<std::chrono::microseconds> CNode::m_min_ping_time {std::chrono::microseconds::max()} |
◆ m_permission_flags
◆ m_prefer_evict
| const bool CNode::m_prefer_evict {false} |
◆ m_relays_txs
| std::atomic_bool CNode::m_relays_txs {false} |
Whether we should relay transactions to this peer (their version message did not include fRelay=false and this is not a block-relay-only connection).
This only changes from false to true. It will never change back to false. Used only in inbound eviction logic.
Definition at line 499 of file net.h.
◆ m_serializer
◆ m_sock_mutex
| Mutex CNode::m_sock_mutex |
◆ m_subver_mutex
| Mutex CNode::m_subver_mutex |
◆ nKeyedNetGroup
| const uint64_t CNode::nKeyedNetGroup |
◆ nLocalHostNonce
| const uint64_t CNode::nLocalHostNonce |
|
private |
◆ nRefCount
| std::atomic<int> CNode::nRefCount {0} |
◆ nTimeOffset
| std::atomic<int64_t> CNode::nTimeOffset {0} |
◆ nVersion
| std::atomic<int> CNode::nVersion {0} |
◆ vRecvMsg
The documentation for this class was generated from the following files: