Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
| Show First 20 Lines • Show All 680 Lines • ▼ Show 20 Lines | public: | ||||
| /** | /** | ||||
| * Lowest measured round-trip time. Used as an inbound peer eviction | * Lowest measured round-trip time. Used as an inbound peer eviction | ||||
| * criterium in CConnman::AttemptToEvictConnection. | * criterium in CConnman::AttemptToEvictConnection. | ||||
| */ | */ | ||||
| std::atomic<std::chrono::microseconds> m_min_ping_time{ | std::atomic<std::chrono::microseconds> m_min_ping_time{ | ||||
| std::chrono::microseconds::max()}; | std::chrono::microseconds::max()}; | ||||
| CNode(NodeId id, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, | CNode(NodeId id, SOCKET hSocketIn, const CAddress &addrIn, | ||||
| const CAddress &addrIn, uint64_t nKeyedNetGroupIn, | uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, | ||||
| uint64_t nLocalHostNonceIn, uint64_t nLocalExtraEntropyIn, | uint64_t nLocalExtraEntropyIn, const CAddress &addrBindIn, | ||||
| const CAddress &addrBindIn, const std::string &addrNameIn, | const std::string &addrNameIn, ConnectionType conn_type_in, | ||||
| ConnectionType conn_type_in, bool inbound_onion); | bool inbound_onion); | ||||
| ~CNode(); | ~CNode(); | ||||
| CNode(const CNode &) = delete; | CNode(const CNode &) = delete; | ||||
| CNode &operator=(const CNode &) = delete; | CNode &operator=(const CNode &) = delete; | ||||
| /** | /** | ||||
| * A ping-pong round trip has completed successfully. Update latest and | * A ping-pong round trip has completed successfully. Update latest and | ||||
| * minimum ping times. | * minimum ping times. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public: | ||||
| } | } | ||||
| void Release() { nRefCount--; } | void Release() { nRefCount--; } | ||||
| void CloseSocketDisconnect(); | void CloseSocketDisconnect(); | ||||
| void copyStats(CNodeStats &stats); | void copyStats(CNodeStats &stats); | ||||
| ServiceFlags GetLocalServices() const { return nLocalServices; } | |||||
| std::string ConnectionTypeAsString() const { | std::string ConnectionTypeAsString() const { | ||||
| return ::ConnectionTypeAsString(m_conn_type); | return ::ConnectionTypeAsString(m_conn_type); | ||||
| } | } | ||||
| 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}; | std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION}; | ||||
| //! Services offered to this peer. | |||||
| const ServiceFlags nLocalServices; | |||||
| NetPermissionFlags m_permissionFlags{NetPermissionFlags::None}; | NetPermissionFlags m_permissionFlags{NetPermissionFlags::None}; | ||||
| // Used only by SocketHandler thread | // Used only by SocketHandler thread | ||||
| std::list<CNetMessage> vRecvMsg; | std::list<CNetMessage> vRecvMsg; | ||||
| // Our address, as reported by the peer | // Our address, as reported by the peer | ||||
| mutable Mutex m_addr_local_mutex; | mutable Mutex m_addr_local_mutex; | ||||
| CService addrLocal GUARDED_BY(m_addr_local_mutex); | CService addrLocal GUARDED_BY(m_addr_local_mutex); | ||||
| ▲ Show 20 Lines • Show All 455 Lines • ▼ Show 20 Lines | private: | ||||
| * The used memory equals to 1000 CAddress records (or around 40 bytes) per | * The used memory equals to 1000 CAddress records (or around 40 bytes) per | ||||
| * distinct Network (up to 5) we have/had an inbound peer from, | * distinct Network (up to 5) we have/had an inbound peer from, | ||||
| * resulting in at most ~196 KB. Every separate local socket may | * resulting in at most ~196 KB. Every separate local socket may | ||||
| * add up to ~196 KB extra. | * add up to ~196 KB extra. | ||||
| */ | */ | ||||
| std::map<uint64_t, CachedAddrResponse> m_addr_response_caches; | std::map<uint64_t, CachedAddrResponse> m_addr_response_caches; | ||||
| /** | /** | ||||
| * Services this instance offers. | * Services this node offers. | ||||
| * | * | ||||
| * This data is replicated in each CNode instance we create during peer | * This data is replicated in each Peer instance we create. | ||||
| * connection (in ConnectNode()) under a member also called | |||||
| * nLocalServices. | |||||
| * | * | ||||
| * This data is not marked const, but after being set it should not | * This data is not marked const, but after being set it should not | ||||
| * change. See the note in CNode::nLocalServices documentation. | * change. | ||||
| * | * | ||||
| * \sa CNode::nLocalServices | * \sa Peer::m_our_services | ||||
| */ | */ | ||||
| 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 | ||||
| ▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines | |||||