Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show First 20 Lines • Show All 830 Lines • ▼ Show 20 Lines | public: | ||||
RecursiveMutex cs_vProcessMsg; | RecursiveMutex cs_vProcessMsg; | ||||
std::list<CNetMessage> vProcessMsg GUARDED_BY(cs_vProcessMsg); | std::list<CNetMessage> vProcessMsg GUARDED_BY(cs_vProcessMsg); | ||||
size_t nProcessQueueSize{0}; | size_t nProcessQueueSize{0}; | ||||
RecursiveMutex cs_sendProcessing; | RecursiveMutex cs_sendProcessing; | ||||
std::deque<CInv> vRecvGetData; | std::deque<CInv> vRecvGetData; | ||||
uint64_t nRecvBytes GUARDED_BY(cs_vRecv){0}; | uint64_t nRecvBytes GUARDED_BY(cs_vRecv){0}; | ||||
std::atomic<int> nRecvVersion{INIT_PROTO_VERSION}; | |||||
std::atomic<int64_t> nLastSend{0}; | std::atomic<int64_t> nLastSend{0}; | ||||
std::atomic<int64_t> nLastRecv{0}; | std::atomic<int64_t> nLastRecv{0}; | ||||
const int64_t nTimeConnected; | const int64_t nTimeConnected; | ||||
std::atomic<int64_t> nTimeOffset{0}; | std::atomic<int64_t> nTimeOffset{0}; | ||||
// Address of this peer | // Address of this peer | ||||
const CAddress addr; | const CAddress addr; | ||||
// Bind address of our side of the connection | // Bind address of our side of the connection | ||||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | public: | ||||
CNode(const CNode &) = delete; | CNode(const CNode &) = delete; | ||||
CNode &operator=(const CNode &) = delete; | CNode &operator=(const CNode &) = delete; | ||||
private: | private: | ||||
const NodeId id; | const NodeId id; | ||||
const uint64_t nLocalHostNonce; | const uint64_t nLocalHostNonce; | ||||
const uint64_t nLocalExtraEntropy; | const uint64_t nLocalExtraEntropy; | ||||
const ConnectionType m_conn_type; | const ConnectionType m_conn_type; | ||||
std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION}; | |||||
//! Services offered to this peer. | //! Services offered to this peer. | ||||
//! | //! | ||||
//! This is supplied by the parent CConnman during peer connection | //! This is supplied by the parent CConnman during peer connection | ||||
//! (CConnman::ConnectNode()) from its attribute of the same name. | //! (CConnman::ConnectNode()) from its attribute of the same name. | ||||
//! | //! | ||||
//! This is const because there is no protocol defined for renegotiating | //! This is const because there is no protocol defined for renegotiating | ||||
//! services initially offered to a peer. The set of local services we | //! services initially offered to a peer. The set of local services we | ||||
//! offer should not change after initialization. | //! offer should not change after initialization. | ||||
//! | //! | ||||
//! An interesting example of this is NODE_NETWORK and initial block | //! An interesting example of this is NODE_NETWORK and initial block | ||||
//! download: a node which starts up from scratch doesn't have any blocks | //! download: a node which starts up from scratch doesn't have any blocks | ||||
//! to serve, but still advertises NODE_NETWORK because it will eventually | //! to serve, but still advertises NODE_NETWORK because it will eventually | ||||
//! fulfill this role after IBD completes. P2P code is written in such a | //! 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 | //! way that it can gracefully handle peers who don't make good on their | ||||
//! service advertisements. | //! service advertisements. | ||||
const ServiceFlags nLocalServices; | const ServiceFlags nLocalServices; | ||||
const int nMyStartingHeight; | const int nMyStartingHeight; | ||||
int nSendVersion{0}; | |||||
NetPermissionFlags m_permissionFlags{PF_NONE}; | NetPermissionFlags m_permissionFlags{PF_NONE}; | ||||
// Used only by SocketHandler thread | // Used only by SocketHandler thread | ||||
std::list<CNetMessage> vRecvMsg; | std::list<CNetMessage> vRecvMsg; | ||||
mutable RecursiveMutex cs_addrName; | mutable RecursiveMutex cs_addrName; | ||||
std::string addrName GUARDED_BY(cs_addrName); | std::string addrName GUARDED_BY(cs_addrName); | ||||
// Our address, as reported by the peer | // Our address, as reported by the peer | ||||
Show All 11 Lines | public: | ||||
int GetRefCount() const { | int GetRefCount() const { | ||||
assert(nRefCount >= 0); | assert(nRefCount >= 0); | ||||
return nRefCount; | return nRefCount; | ||||
} | } | ||||
bool ReceiveMsgBytes(const Config &config, const char *pch, uint32_t nBytes, | bool ReceiveMsgBytes(const Config &config, const char *pch, uint32_t nBytes, | ||||
bool &complete); | bool &complete); | ||||
void SetRecvVersion(int nVersionIn) { nRecvVersion = nVersionIn; } | void SetCommonVersion(int greatest_common_version) { | ||||
int GetRecvVersion() const { return nRecvVersion; } | m_greatest_common_version = greatest_common_version; | ||||
void SetSendVersion(int nVersionIn); | } | ||||
int GetSendVersion() const; | int GetCommonVersion() const { return m_greatest_common_version; } | ||||
CService GetAddrLocal() const; | CService GetAddrLocal() const; | ||||
//! May not be called more than once | //! May not be called more than once | ||||
void SetAddrLocal(const CService &addrLocalIn); | void SetAddrLocal(const CService &addrLocalIn); | ||||
CNode *AddRef() { | CNode *AddRef() { | ||||
nRefCount++; | nRefCount++; | ||||
return this; | return this; | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |