Bitcoin Core  0.18.99
P2P Digital Currency
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
CNode Class Reference

Information about a peer. More...

#include <net.h>

Collaboration diagram for CNode:

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 fRelayTxes GUARDED_BY (cs_filter)
std::unique_ptr< CBloomFilter > pfilter PT_GUARDED_BY (cs_filter)
int64_t nNextAddrSend GUARDED_BY (cs_sendProcessing)
int64_t nNextLocalAddrSend GUARDED_BY (cs_sendProcessing)
CRollingBloomFilter filterInventoryKnown GUARDED_BY (cs_inventory)
std::vector< uint256 > vInventoryBlockToSend GUARDED_BY (cs_inventory)
std::vector< uint256 > vBlockHashesToAnnounce GUARDED_BY (cs_inventory)
bool fSendMempool GUARDED_BY (cs_inventory)
CAmount minFeeFilter GUARDED_BY (cs_feeFilter)
 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="", bool fInboundIn=false)
 ~CNode ()
 CNode (const CNode &)=delete
CNodeoperator= (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 SetRecvVersion (int nVersionIn)
int GetRecvVersion () const
void SetSendVersion (int nVersionIn)
int GetSendVersion () const
CService GetAddrLocal () const
void SetAddrLocal (const CService &addrLocalIn)
 May not be called more than once. More...
CNodeAddRef ()
void Release ()
void AddAddressKnown (const CAddress &_addr)
void PushAddress (const CAddress &_addr, FastRandomContext &insecure_rand)
void AddInventoryKnown (const CInv &inv)
void PushInventory (const CInv &inv)
void PushBlockHash (const uint256 &hash)
void CloseSocketDisconnect ()
void copyStats (CNodeStats &stats)
ServiceFlags GetLocalServices () const
std::string GetAddrName () const
void MaybeSetAddrName (const std::string &addrNameIn)
 Sets the addrName only if it was not previously set. More...

Public Attributes

std::atomic< ServiceFlagsnServices {NODE_NONE}
size_t nSendSize {0}
size_t nSendOffset {0}
CCriticalSection cs_vSend
CCriticalSection cs_hSocket
CCriticalSection cs_vRecv
CCriticalSection cs_vProcessMsg
size_t nProcessQueueSize {0}
CCriticalSection cs_sendProcessing
std::deque< CInvvRecvGetData
std::atomic< int > nRecvVersion {INIT_PROTO_VERSION}
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 fWhitelisted {false}
bool fFeeler {false}
bool fOneShot {false}
bool m_manual_connection {false}
bool fClient {false}
bool m_limited_node {false}
const bool fInbound
std::atomic_bool fSuccessfullyConnected {false}
std::atomic_bool fDisconnect {false}
bool fSentAddr {false}
CSemaphoreGrant grantOutbound
CCriticalSection cs_filter
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< CAddressvAddrToSend
CRollingBloomFilter addrKnown
bool fGetAddr {false}
std::set< uint256setKnown
std::set< uint256setInventoryTxToSend
CCriticalSection cs_inventory
int64_t nNextInvSend {0}
std::atomic< int64_t > timeLastMempoolReq {0}
std::atomic< int64_t > nLastBlockTime {0}
std::atomic< int64_t > nLastTXTime {0}
std::atomic< uint64_t > nPingNonceSent {0}
std::atomic< int64_t > nPingUsecStart {0}
std::atomic< int64_t > nPingUsecTime {0}
std::atomic< int64_t > nMinPingUsecTime {std::numeric_limits<int64_t>::max()}
std::atomic< bool > fPingQueued {false}
CCriticalSection cs_feeFilter
CAmount lastSentFeeFilter {0}
int64_t nextSendTimeFeeFilter {0}
std::set< uint256orphan_work_set

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 ServiceFlags nLocalServices
const int nMyStartingHeight
int nSendVersion {0}
std::list< CNetMessagevRecvMsg
CCriticalSection cs_addrName
CCriticalSection cs_addrLocal


class CConnman

Detailed Description

Information about a peer.

Definition at line 619 of file net.h.

Constructor & Destructor Documentation

◆ CNode() [1/2]

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 = "",
bool  fInboundIn = false 

Definition at line 2615 of file net.cpp.

Here is the call graph for this function:

◆ ~CNode()

CNode::~CNode ( )

Definition at line 2645 of file net.cpp.

Here is the call graph for this function:

◆ CNode() [2/2]

CNode::CNode ( const CNode )

Member Function Documentation

◆ AddAddressKnown()

void CNode::AddAddressKnown ( const CAddress _addr)

Definition at line 814 of file net.h.

Here is the call graph for this function:

◆ AddInventoryKnown()

void CNode::AddInventoryKnown ( const CInv inv)

Definition at line 834 of file net.h.

◆ AddRef()

CNode* CNode::AddRef ( )

Definition at line 801 of file net.h.

◆ CloseSocketDisconnect()

void CNode::CloseSocketDisconnect ( )

Definition at line 447 of file net.cpp.

◆ copyStats()

void CNode::copyStats ( CNodeStats stats)

Definition at line 494 of file net.cpp.

Here is the call graph for this function:

◆ GetAddrLocal()

CService CNode::GetAddrLocal ( ) const

Definition at line 478 of file net.cpp.

Here is the caller graph for this function:

◆ GetAddrName()

std::string CNode::GetAddrName ( ) const

Definition at line 466 of file net.cpp.

Here is the caller graph for this function:

◆ GetId()

NodeId CNode::GetId ( ) const

Definition at line 766 of file net.h.

Here is the caller graph for this function:

◆ GetLocalNonce()

uint64_t CNode::GetLocalNonce ( ) const

Definition at line 770 of file net.h.

◆ GetLocalServices()

ServiceFlags CNode::GetLocalServices ( ) const

Definition at line 864 of file net.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMyStartingHeight()

int CNode::GetMyStartingHeight ( ) const

Definition at line 774 of file net.h.

◆ GetRecvVersion()

int CNode::GetRecvVersion ( ) const

Definition at line 790 of file net.h.

◆ GetRefCount()

int CNode::GetRefCount ( ) const

Definition at line 778 of file net.h.

◆ GetSendVersion()

int CNode::GetSendVersion ( ) const

Definition at line 620 of file net.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GUARDED_BY() [1/17]

SOCKET hSocket CNode::GUARDED_BY ( cs_hSocket  )

◆ GUARDED_BY() [2/17]

uint64_t nSendBytes CNode::GUARDED_BY ( cs_vSend  )

Definition at line 628 of file net.h.

Here is the call graph for this function:

◆ GUARDED_BY() [3/17]

std::deque<std::vector<unsigned char> > vSendMsg CNode::GUARDED_BY ( cs_vSend  )

◆ GUARDED_BY() [4/17]

std::list<CNetMessage> vProcessMsg CNode::GUARDED_BY ( cs_vProcessMsg  )

◆ GUARDED_BY() [5/17]

uint64_t nRecvBytes CNode::GUARDED_BY ( cs_vRecv  )

Definition at line 641 of file net.h.

◆ GUARDED_BY() [6/17]

std::string cleanSubVer CNode::GUARDED_BY ( cs_SubVer  )

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 658 of file net.h.

◆ GUARDED_BY() [7/17]

bool fRelayTxes CNode::GUARDED_BY ( cs_filter  )

Definition at line 675 of file net.h.

◆ GUARDED_BY() [8/17]

mapMsgCmdSize mapRecvBytesPerMsgCmd CNode::GUARDED_BY ( cs_vRecv  )

◆ GUARDED_BY() [9/17]

int64_t nNextAddrSend CNode::GUARDED_BY ( cs_sendProcessing  )

Definition at line 699 of file net.h.

◆ GUARDED_BY() [10/17]

int64_t nNextLocalAddrSend CNode::GUARDED_BY ( cs_sendProcessing  )

Definition at line 700 of file net.h.

Here is the call graph for this function:

◆ GUARDED_BY() [11/17]

CRollingBloomFilter filterInventoryKnown CNode::GUARDED_BY ( cs_inventory  )

◆ GUARDED_BY() [12/17]

std::vector<uint256> vInventoryBlockToSend CNode::GUARDED_BY ( cs_inventory  )

◆ GUARDED_BY() [13/17]

std::vector<uint256> vBlockHashesToAnnounce CNode::GUARDED_BY ( cs_inventory  )

◆ GUARDED_BY() [14/17]

bool fSendMempool CNode::GUARDED_BY ( cs_inventory  )

Definition at line 716 of file net.h.

◆ GUARDED_BY() [15/17]

CAmount minFeeFilter CNode::GUARDED_BY ( cs_feeFilter  )

Definition at line 737 of file net.h.

◆ GUARDED_BY() [16/17]

std::string addrName CNode::GUARDED_BY ( cs_addrName  )

◆ GUARDED_BY() [17/17]

CService addrLocal CNode::GUARDED_BY ( cs_addrLocal  )

◆ MaybeSetAddrName()

void CNode::MaybeSetAddrName ( const std::string &  addrNameIn)

Sets the addrName only if it was not previously set.

Definition at line 471 of file net.cpp.

◆ operator=()

CNode& CNode::operator= ( const CNode )


std::unique_ptr<CBloomFilter> pfilter CNode::PT_GUARDED_BY ( cs_filter  )

◆ PushAddress()

void CNode::PushAddress ( const CAddress _addr,
FastRandomContext insecure_rand 

Definition at line 819 of file net.h.

Here is the call graph for this function:

◆ PushBlockHash()

void CNode::PushBlockHash ( const uint256 hash)

Definition at line 854 of file net.h.

◆ PushInventory()

void CNode::PushInventory ( const CInv inv)

Definition at line 842 of file net.h.

Here is the caller graph for this function:

◆ ReceiveMsgBytes()

bool CNode::ReceiveMsgBytes ( const char *  pch,
unsigned int  nBytes,
bool &  complete 

Definition at line 555 of file net.cpp.

Here is the call graph for this function:

◆ Release()

void CNode::Release ( )

Definition at line 807 of file net.h.

◆ SetAddrLocal()

void CNode::SetAddrLocal ( const CService addrLocalIn)

May not be called more than once.

Definition at line 483 of file net.cpp.

Here is the call graph for this function:

◆ SetRecvVersion()

void CNode::SetRecvVersion ( int  nVersionIn)

Definition at line 786 of file net.h.

◆ SetSendVersion()

void CNode::SetSendVersion ( int  nVersionIn)

Definition at line 606 of file net.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ CConnman

friend class CConnman

Definition at line 621 of file net.h.

Member Data Documentation

◆ addr

const CAddress CNode::addr

Definition at line 649 of file net.h.

◆ addrBind

const CAddress CNode::addrBind

Definition at line 651 of file net.h.

◆ addrKnown

CRollingBloomFilter CNode::addrKnown

Definition at line 696 of file net.h.

◆ cs_addrLocal

CCriticalSection CNode::cs_addrLocal

Definition at line 763 of file net.h.

◆ cs_addrName

CCriticalSection CNode::cs_addrName

Definition at line 758 of file net.h.

◆ cs_feeFilter

CCriticalSection CNode::cs_feeFilter

Definition at line 737 of file net.h.

◆ cs_filter

CCriticalSection CNode::cs_filter

Definition at line 678 of file net.h.

◆ cs_hSocket

CCriticalSection CNode::cs_hSocket

Definition at line 631 of file net.h.

◆ cs_inventory

CCriticalSection CNode::cs_inventory

Definition at line 711 of file net.h.

◆ cs_sendProcessing

CCriticalSection CNode::cs_sendProcessing

Definition at line 638 of file net.h.

◆ cs_SubVer

RecursiveMutex CNode::cs_SubVer

Definition at line 653 of file net.h.

◆ cs_vProcessMsg

CCriticalSection CNode::cs_vProcessMsg

Definition at line 634 of file net.h.

◆ cs_vRecv

CCriticalSection CNode::cs_vRecv

Definition at line 632 of file net.h.

◆ cs_vSend

CCriticalSection CNode::cs_vSend

Definition at line 630 of file net.h.

◆ fClient

bool CNode::fClient {false}

Definition at line 664 of file net.h.

◆ fDisconnect

std::atomic_bool CNode::fDisconnect {false}

Definition at line 670 of file net.h.

◆ fFeeler

bool CNode::fFeeler {false}

Definition at line 661 of file net.h.

◆ fGetAddr

bool CNode::fGetAddr {false}

Definition at line 697 of file net.h.

◆ fInbound

const bool CNode::fInbound

Definition at line 666 of file net.h.

◆ fOneShot

bool CNode::fOneShot {false}

Definition at line 662 of file net.h.

◆ fPauseRecv

std::atomic_bool CNode::fPauseRecv {false}

Definition at line 683 of file net.h.

◆ fPauseSend

std::atomic_bool CNode::fPauseSend {false}

Definition at line 684 of file net.h.

◆ fPingQueued

std::atomic<bool> CNode::fPingQueued {false}

Definition at line 735 of file net.h.

◆ fSentAddr

bool CNode::fSentAddr {false}

Definition at line 676 of file net.h.

◆ fSuccessfullyConnected

std::atomic_bool CNode::fSuccessfullyConnected {false}

Definition at line 667 of file net.h.

◆ fWhitelisted

bool CNode::fWhitelisted {false}

Definition at line 660 of file net.h.

◆ grantOutbound

CSemaphoreGrant CNode::grantOutbound

Definition at line 677 of file net.h.

◆ hashContinue

uint256 CNode::hashContinue

Definition at line 691 of file net.h.

◆ id

const NodeId CNode::id

Definition at line 750 of file net.h.

◆ lastSentFeeFilter

CAmount CNode::lastSentFeeFilter {0}

Definition at line 739 of file net.h.

◆ m_limited_node

bool CNode::m_limited_node {false}

Definition at line 665 of file net.h.

◆ m_manual_connection

bool CNode::m_manual_connection {false}

Definition at line 663 of file net.h.

◆ m_prefer_evict

bool CNode::m_prefer_evict {false}

Definition at line 659 of file net.h.

◆ mapSendBytesPerMsgCmd

mapMsgCmdSize CNode::mapSendBytesPerMsgCmd

Definition at line 687 of file net.h.

◆ nextSendTimeFeeFilter

int64_t CNode::nextSendTimeFeeFilter {0}

Definition at line 740 of file net.h.

◆ nKeyedNetGroup

const uint64_t CNode::nKeyedNetGroup

Definition at line 682 of file net.h.

◆ nLastBlockTime

std::atomic<int64_t> CNode::nLastBlockTime {0}

Definition at line 722 of file net.h.

◆ nLastRecv

std::atomic<int64_t> CNode::nLastRecv {0}

Definition at line 645 of file net.h.

◆ nLastSend

std::atomic<int64_t> CNode::nLastSend {0}

Definition at line 644 of file net.h.

◆ nLastTXTime

std::atomic<int64_t> CNode::nLastTXTime {0}

Definition at line 723 of file net.h.

◆ nLocalHostNonce

const uint64_t CNode::nLocalHostNonce

Definition at line 751 of file net.h.

◆ nLocalServices

const ServiceFlags CNode::nLocalServices

Definition at line 753 of file net.h.

◆ nMinPingUsecTime

std::atomic<int64_t> CNode::nMinPingUsecTime {std::numeric_limits<int64_t>::max()}

Definition at line 733 of file net.h.

◆ nMyStartingHeight

const int CNode::nMyStartingHeight

Definition at line 754 of file net.h.

◆ nNextInvSend

int64_t CNode::nNextInvSend {0}

Definition at line 712 of file net.h.

◆ nPingNonceSent

std::atomic<uint64_t> CNode::nPingNonceSent {0}

Definition at line 727 of file net.h.

◆ nPingUsecStart

std::atomic<int64_t> CNode::nPingUsecStart {0}

Definition at line 729 of file net.h.

◆ nPingUsecTime

std::atomic<int64_t> CNode::nPingUsecTime {0}

Definition at line 731 of file net.h.

◆ nProcessQueueSize

size_t CNode::nProcessQueueSize {0}

Definition at line 636 of file net.h.

◆ nRecvVersion

std::atomic<int> CNode::nRecvVersion {INIT_PROTO_VERSION}

Definition at line 642 of file net.h.

◆ nRefCount

std::atomic<int> CNode::nRefCount {0}

Definition at line 680 of file net.h.

◆ nSendOffset

size_t CNode::nSendOffset {0}

Definition at line 627 of file net.h.

◆ nSendSize

size_t CNode::nSendSize {0}

Definition at line 626 of file net.h.

◆ nSendVersion

int CNode::nSendVersion {0}

Definition at line 755 of file net.h.

◆ nServices

std::atomic<ServiceFlags> CNode::nServices {NODE_NONE}

Definition at line 624 of file net.h.

◆ nStartingHeight

std::atomic<int> CNode::nStartingHeight {-1}

Definition at line 692 of file net.h.

◆ nTimeConnected

const int64_t CNode::nTimeConnected

Definition at line 646 of file net.h.

◆ nTimeOffset

std::atomic<int64_t> CNode::nTimeOffset {0}

Definition at line 647 of file net.h.

◆ nVersion

std::atomic<int> CNode::nVersion {0}

Definition at line 652 of file net.h.

◆ orphan_work_set

std::set<uint256> CNode::orphan_work_set

Definition at line 742 of file net.h.

◆ setInventoryTxToSend

std::set<uint256> CNode::setInventoryTxToSend

Definition at line 706 of file net.h.

◆ setKnown

std::set<uint256> CNode::setKnown

Definition at line 698 of file net.h.

◆ timeLastMempoolReq

std::atomic<int64_t> CNode::timeLastMempoolReq {0}

Definition at line 719 of file net.h.

◆ vAddrToSend

std::vector<CAddress> CNode::vAddrToSend

Definition at line 695 of file net.h.

◆ vRecvGetData

std::deque<CInv> CNode::vRecvGetData

Definition at line 640 of file net.h.

◆ vRecvMsg

std::list<CNetMessage> CNode::vRecvMsg

Definition at line 756 of file net.h.

The documentation for this class was generated from the following files: