Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show First 20 Lines • Show All 301 Lines • ▼ Show 20 Lines | public: | ||||
size_t GetNodeCount(NumConnections num); | size_t GetNodeCount(NumConnections num); | ||||
void GetNodeStats(std::vector<CNodeStats> &vstats); | void GetNodeStats(std::vector<CNodeStats> &vstats); | ||||
bool DisconnectNode(const std::string &node); | bool DisconnectNode(const std::string &node); | ||||
bool DisconnectNode(const CSubNet &subnet); | bool DisconnectNode(const CSubNet &subnet); | ||||
bool DisconnectNode(const CNetAddr &addr); | bool DisconnectNode(const CNetAddr &addr); | ||||
bool DisconnectNode(NodeId id); | bool DisconnectNode(NodeId id); | ||||
//! Used to convey which local services we are offering peers during node | |||||
//! connection. | |||||
//! | |||||
//! The data returned by this is used in CNode construction, | |||||
//! which is used to advertise which services we are offering | |||||
//! that peer during `net_processing.cpp:PushNodeVersion()`. | |||||
ServiceFlags GetLocalServices() const; | ServiceFlags GetLocalServices() const; | ||||
//! set the max outbound target in bytes. | //! set the max outbound target in bytes. | ||||
void SetMaxOutboundTarget(uint64_t limit); | void SetMaxOutboundTarget(uint64_t limit); | ||||
uint64_t GetMaxOutboundTarget(); | uint64_t GetMaxOutboundTarget(); | ||||
//! set the timeframe for the max outbound target. | //! set the timeframe for the max outbound target. | ||||
void SetMaxOutboundTimeframe(uint64_t timeframe); | void SetMaxOutboundTimeframe(uint64_t timeframe); | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | private: | ||||
std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes); | std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes); | ||||
RecursiveMutex cs_vAddedNodes; | RecursiveMutex cs_vAddedNodes; | ||||
std::vector<CNode *> vNodes GUARDED_BY(cs_vNodes); | std::vector<CNode *> vNodes GUARDED_BY(cs_vNodes); | ||||
std::list<CNode *> vNodesDisconnected; | std::list<CNode *> vNodesDisconnected; | ||||
mutable RecursiveMutex cs_vNodes; | mutable RecursiveMutex cs_vNodes; | ||||
std::atomic<NodeId> nLastNodeId{0}; | std::atomic<NodeId> nLastNodeId{0}; | ||||
unsigned int nPrevNodeCount{0}; | unsigned int nPrevNodeCount{0}; | ||||
/** Services this instance offers */ | /** | ||||
* Services this instance offers. | |||||
* | |||||
* This data is replicated in each CNode instance we create during peer | |||||
* connection (in ConnectNode()) under a member also called | |||||
* nLocalServices. | |||||
* | |||||
* This data is not marked const, but after being set it should not | |||||
* change. See the note in CNode::nLocalServices documentation. | |||||
* | |||||
* \sa CNode::nLocalServices | |||||
*/ | |||||
ServiceFlags nLocalServices; | ServiceFlags nLocalServices; | ||||
std::unique_ptr<CSemaphore> semOutbound; | std::unique_ptr<CSemaphore> semOutbound; | ||||
std::unique_ptr<CSemaphore> semAddnode; | std::unique_ptr<CSemaphore> semAddnode; | ||||
int nMaxConnections; | int nMaxConnections; | ||||
// How many full-relay (tx, block, addr) outbound peers we want | // How many full-relay (tx, block, addr) outbound peers we want | ||||
int m_max_outbound_full_relay; | int m_max_outbound_full_relay; | ||||
▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Lines | CNode(NodeId id, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, | ||||
bool block_relay_only = false); | bool block_relay_only = false); | ||||
~CNode(); | ~CNode(); | ||||
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; | ||||
// Services offered to this peer | |||||
//! 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. | |||||
const ServiceFlags nLocalServices; | const ServiceFlags nLocalServices; | ||||
const int nMyStartingHeight; | const int nMyStartingHeight; | ||||
int nSendVersion{0}; | 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); | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |