![]() |
Bitcoin Core
0.21.1
P2P Digital Currency
|
Information about a peer. More...
#include <net.h>
Classes | |
| struct | TxRelay |
Public Member Functions | |
| SOCKET hSocket | GUARDED_BY (cs_hSocket) |
| 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 (cs_SubVer) |
| 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 | RelayAddrsWithConn () const |
| bool | ExpectServicesFromConn () const |
| Network | ConnectedThroughNetwork () const |
| Get network the peer connected through. More... | |
| std::chrono::microseconds m_next_addr_send | GUARDED_BY (cs_sendProcessing) |
| std::chrono::microseconds m_next_local_addr_send | GUARDED_BY (cs_sendProcessing) |
| std::vector< uint256 > vInventoryBlockToSend | GUARDED_BY (cs_inventory) |
| std::vector< uint256 > vBlockHashesToAnnounce | GUARDED_BY (cs_inventory) |
| CNode (NodeId id, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress &addrBindIn, const std::string &addrNameIn, ConnectionType conn_type_in, bool inbound_onion=false) | |
| ~CNode () | |
| CNode (const CNode &)=delete | |
| CNode & | operator= (const CNode &)=delete |
| NodeId | GetId () const |
| uint64_t | GetLocalNonce () const |
| int | GetMyStartingHeight () const |
| int | GetRefCount () const |
| bool | ReceiveMsgBytes (const char *pch, unsigned int nBytes, bool &complete) |
| void | SetCommonVersion (int greatest_common_version) |
| int | GetCommonVersion () const |
| CService | GetAddrLocal () const |
| void | SetAddrLocal (const CService &addrLocalIn) |
| May not be called more than once. More... | |
| CNode * | AddRef () |
| void | Release () |
| void | AddAddressKnown (const CAddress &_addr) |
| void | PushAddress (const CAddress &_addr, FastRandomContext &insecure_rand) |
| void | AddKnownTx (const uint256 &hash) |
| void | PushTxInventory (const uint256 &hash) |
| void | CloseSocketDisconnect () |
| void | copyStats (CNodeStats &stats, const std::vector< bool > &m_asmap) |
| ServiceFlags | GetLocalServices () const |
| std::string | GetAddrName () const |
| void | MaybeSetAddrName (const std::string &addrNameIn) |
| Sets the addrName only if it was not previously set. More... | |
| std::string | ConnectionTypeAsString () const |
Public Attributes | |
| std::unique_ptr < TransportDeserializer > | m_deserializer |
| std::unique_ptr < TransportSerializer > | m_serializer |
| std::atomic< ServiceFlags > | nServices {NODE_NONE} |
| size_t | nSendSize {0} |
| size_t | nSendOffset {0} |
| RecursiveMutex | cs_vSend |
| RecursiveMutex | cs_hSocket |
| RecursiveMutex | cs_vRecv |
| RecursiveMutex | cs_vProcessMsg |
| size_t | nProcessQueueSize {0} |
| RecursiveMutex | cs_sendProcessing |
| std::atomic< int64_t > | nLastSend {0} |
| std::atomic< int64_t > | nLastRecv {0} |
| const int64_t | nTimeConnected |
| std::atomic< int64_t > | nTimeOffset {0} |
| const CAddress | addr |
| const CAddress | addrBind |
| std::atomic< int > | nVersion {0} |
| RecursiveMutex | cs_SubVer |
| bool | m_prefer_evict {false} |
| bool | m_legacyWhitelisted {false} |
| bool | fClient {false} |
| bool | m_limited_node {false} |
| std::atomic_bool | m_wants_addrv2 {false} |
| Whether the peer has signaled support for receiving ADDRv2 (BIP155) messages, implying a preference to receive ADDRv2 instead of ADDR ones. More... | |
| std::atomic_bool | fSuccessfullyConnected {false} |
| std::atomic_bool | fDisconnect {false} |
| bool | fSentAddr {false} |
| CSemaphoreGrant | grantOutbound |
| std::atomic< int > | nRefCount {0} |
| const uint64_t | nKeyedNetGroup |
| std::atomic_bool | fPauseRecv {false} |
| std::atomic_bool | fPauseSend {false} |
| uint256 | hashContinue |
| std::atomic< int > | nStartingHeight {-1} |
| std::vector< CAddress > | vAddrToSend |
| std::unique_ptr < CRollingBloomFilter > | m_addr_known {nullptr} |
| bool | fGetAddr {false} |
| Mutex | cs_inventory |
| std::unique_ptr< TxRelay > | m_tx_relay |
| std::atomic< int64_t > | nLastBlockTime {0} |
| UNIX epoch time of the last block received from this peer that we had not yet seen (e.g. More... | |
| std::atomic< int64_t > | nLastTXTime {0} |
| UNIX epoch time of the last transaction received from this peer that we had not yet seen (e.g. More... | |
| std::atomic< uint64_t > | nPingNonceSent {0} |
| std::atomic < std::chrono::microseconds > | m_ping_start {std::chrono::microseconds{0}} |
| When the last ping was sent, or 0 if no ping was ever sent. More... | |
| std::atomic< int64_t > | nPingUsecTime {0} |
| std::atomic< int64_t > | nMinPingUsecTime {std::numeric_limits<int64_t>::max()} |
| std::atomic< bool > | fPingQueued {false} |
Protected Member Functions | |
| mapMsgCmdSize mapRecvBytesPerMsgCmd | GUARDED_BY (cs_vRecv) |
Protected Attributes | |
| mapMsgCmdSize | mapSendBytesPerMsgCmd |
Private Member Functions | |
| std::string addrName | GUARDED_BY (cs_addrName) |
| CService addrLocal | GUARDED_BY (cs_addrLocal) |
Private Attributes | |
| const NodeId | id |
| const uint64_t | nLocalHostNonce |
| const ConnectionType | m_conn_type |
| std::atomic< int > | m_greatest_common_version {INIT_PROTO_VERSION} |
| const ServiceFlags | nLocalServices |
| Services offered to this peer. More... | |
| const int | nMyStartingHeight |
| NetPermissionFlags | m_permissionFlags { PF_NONE } |
| std::list< CNetMessage > | vRecvMsg |
| RecursiveMutex | cs_addrName |
| RecursiveMutex | cs_addrLocal |
| const bool | m_inbound_onion {false} |
| Whether this peer connected via our Tor onion service. More... | |
Friends | |
| class | CConnman |
| struct | ConnmanTestMsg |
| CNode::CNode | ( | NodeId | id, |
| ServiceFlags | nLocalServicesIn, | ||
| int | nMyStartingHeightIn, | ||
| SOCKET | hSocketIn, | ||
| const CAddress & | addrIn, | ||
| uint64_t | nKeyedNetGroupIn, | ||
| uint64_t | nLocalHostNonceIn, | ||
| const CAddress & | addrBindIn, | ||
| const std::string & | addrNameIn, | ||
| ConnectionType | conn_type_in, | ||
| bool | inbound_onion = false |
||
| ) |
| CNode::~CNode | ( | ) |
|
delete |
|
inline |
| void CNode::CloseSocketDisconnect | ( | ) |
| 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.
| std::string CNode::ConnectionTypeAsString | ( | ) | const |
| void CNode::copyStats | ( | CNodeStats & | stats, |
| const std::vector< bool > & | m_asmap | ||
| ) |
| CService CNode::GetAddrLocal | ( | ) | const |
| std::string CNode::GetAddrName | ( | ) | const |
|
inline |
| SOCKET hSocket CNode::GUARDED_BY | ( | cs_hSocket | ) |
| std::deque<std::vector<unsigned char> > vSendMsg CNode::GUARDED_BY | ( | cs_vSend | ) |
| std::list<CNetMessage> vProcessMsg CNode::GUARDED_BY | ( | cs_vProcessMsg | ) |
|
inline |
|
protected |
|
inline |
|
inline |
| std::vector<uint256> vInventoryBlockToSend CNode::GUARDED_BY | ( | cs_inventory | ) |
| std::vector<uint256> vBlockHashesToAnnounce CNode::GUARDED_BY | ( | cs_inventory | ) |
|
private |
|
private |
|
inline |
| void CNode::MaybeSetAddrName | ( | const std::string & | addrNameIn | ) |
Sets the addrName only if it was not previously set.
|
inline |
| bool CNode::ReceiveMsgBytes | ( | const char * | pch, |
| unsigned int | nBytes, | ||
| bool & | complete | ||
| ) |
| void CNode::SetAddrLocal | ( | const CService & | addrLocalIn | ) |
May not be called more than once.
|
inline |
|
mutableprivate |
|
mutableprivate |
| RecursiveMutex CNode::cs_hSocket |
| RecursiveMutex CNode::cs_sendProcessing |
| RecursiveMutex CNode::cs_SubVer |
| RecursiveMutex CNode::cs_vProcessMsg |
| RecursiveMutex CNode::cs_vRecv |
| RecursiveMutex CNode::cs_vSend |
| CSemaphoreGrant CNode::grantOutbound |
| std::unique_ptr<CRollingBloomFilter> CNode::m_addr_known {nullptr} |
|
private |
| std::unique_ptr<TransportDeserializer> CNode::m_deserializer |
|
private |
|
private |
|
private |
| std::atomic<std::chrono::microseconds> CNode::m_ping_start {std::chrono::microseconds{0}} |
| std::unique_ptr<TransportSerializer> CNode::m_serializer |
| std::atomic_bool CNode::m_wants_addrv2 {false} |
|
protected |
| std::atomic<int64_t> CNode::nLastBlockTime {0} |
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.
| std::atomic<int64_t> CNode::nLastTXTime {0} |
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.
|
private |
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.
| std::atomic<int64_t> CNode::nMinPingUsecTime {std::numeric_limits<int64_t>::max()} |
| std::atomic<ServiceFlags> CNode::nServices {NODE_NONE} |
|
private |
1.8.8