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) |
|
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, ServiceFlags nLocalServicesIn, 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) |
|
| 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) |
| Receive bytes from the buffer and deserialize them into messages. More...
|
|
void | SetCommonVersion (int greatest_common_version) |
|
int | GetCommonVersion () const |
|
CService | GetAddrLocal () const LOCKS_EXCLUDED(m_addr_local_mutex) |
|
void | SetAddrLocal (const CService &addrLocalIn) LOCKS_EXCLUDED(m_addr_local_mutex) |
| May not be called more than once. More...
|
|
CNode * | AddRef () |
|
void | Release () |
|
void | AddKnownTx (const uint256 &hash) |
|
void | PushTxInventory (const uint256 &hash) |
|
void | CloseSocketDisconnect () |
|
void | CopyStats (CNodeStats &stats) |
|
ServiceFlags | GetLocalServices () const |
|
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 394 of file net.h.
◆ CNode() [1/2]
CNode::CNode |
( |
NodeId |
id, |
|
|
ServiceFlags |
nLocalServicesIn, |
|
|
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 |
|
) |
| |
◆ CNode() [2/2]
CNode::CNode |
( |
const CNode & |
| ) |
|
|
delete |
◆ AddKnownTx()
void CNode::AddKnownTx |
( |
const uint256 & |
hash | ) |
|
|
inline |
◆ 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 580 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 |
◆ GetLocalServices()
◆ GetRefCount()
int CNode::GetRefCount |
( |
| ) |
const |
|
inline |
◆ GUARDED_BY() [1/11]
◆ GUARDED_BY() [2/11]
uint64_t nRecvBytes CNode::GUARDED_BY |
( |
cs_vRecv |
| ) |
|
|
inline |
◆ GUARDED_BY() [3/11]
◆ GUARDED_BY() [4/11]
size_t nSendSize CNode::GUARDED_BY |
( |
cs_vSend |
| ) |
|
|
inline |
Total size of all vSendMsg entries.
Definition at line 417 of file net.h.
◆ GUARDED_BY() [5/11]
size_t nSendOffset CNode::GUARDED_BY |
( |
cs_vSend |
| ) |
|
|
inline |
Offset inside the first vSendMsg already sent.
Definition at line 419 of file net.h.
◆ GUARDED_BY() [6/11]
uint64_t nSendBytes CNode::GUARDED_BY |
( |
cs_vSend |
| ) |
|
|
inline |
◆ GUARDED_BY() [7/11]
std::deque<std::vector<unsigned char> > vSendMsg CNode::GUARDED_BY |
( |
cs_vSend |
| ) |
|
◆ GUARDED_BY() [8/11]
◆ GUARDED_BY() [9/11]
◆ GUARDED_BY() [10/11]
◆ GUARDED_BY() [11/11]
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 452 of file net.h.
◆ 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 674 of file net.h.
◆ PushTxInventory()
void CNode::PushTxInventory |
( |
const uint256 & |
hash | ) |
|
|
inline |
◆ 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 643 of file net.cpp.
◆ Release()
◆ SetAddrLocal()
void CNode::SetAddrLocal |
( |
const CService & |
addrLocalIn | ) |
|
May not be called more than once.
Definition at line 570 of file net.cpp.
◆ SetCommonVersion()
void CNode::SetCommonVersion |
( |
int |
greatest_common_version | ) |
|
|
inline |
◆ CConnman
◆ ConnmanTestMsg
◆ addr
◆ addrBind
◆ cs_sendProcessing
◆ cs_vProcessMsg
◆ cs_vRecv
◆ cs_vSend
◆ fClient
bool CNode::fClient {false} |
◆ 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 460 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_conn_type
◆ m_connected
const std::chrono::seconds CNode::m_connected |
Unix epoch time at peer connection.
Definition at line 437 of file net.h.
◆ m_deserializer
◆ m_greatest_common_version
◆ 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 445 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 576 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 585 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 582 of file net.h.
◆ m_limited_node
bool CNode::m_limited_node {false} |
◆ m_min_ping_time
std::atomic<std::chrono::microseconds> CNode::m_min_ping_time {std::chrono::microseconds::max()} |
◆ m_permissionFlags
◆ m_prefer_evict
bool CNode::m_prefer_evict {false} |
◆ m_serializer
◆ m_sock_mutex
Mutex CNode::m_sock_mutex |
◆ m_subver_mutex
Mutex CNode::m_subver_mutex |
◆ m_tx_relay
std::unique_ptr<TxRelay> CNode::m_tx_relay |
◆ nKeyedNetGroup
const uint64_t CNode::nKeyedNetGroup |
◆ nLocalHostNonce
const uint64_t CNode::nLocalHostNonce |
|
private |
◆ nLocalServices
Services offered to this peer.
This is supplied by the parent CConnman during peer connection (CConnman::ConnectNode()) from its attribute of the same name.
This is const because there is no protocol defined for renegotiating services initially offered to a peer. The set of local services we offer should not change after initialization.
An interesting example of this is NODE_NETWORK and initial block download: a node which starts up from scratch doesn't have any blocks to serve, but still advertises NODE_NETWORK because it will eventually fulfill this role after IBD completes. P2P code is written in such a way that it can gracefully handle peers who don't make good on their service advertisements.
Definition at line 700 of file net.h.
◆ nProcessQueueSize
size_t CNode::nProcessQueueSize {0} |
◆ nRefCount
std::atomic<int> CNode::nRefCount {0} |
◆ nServices
◆ 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: