Bitcoin ABC 0.30.3
P2P Digital Currency
|
Information about a peer. More...
#include <net.h>
Public Member Functions | |
SOCKET hSocket | GUARDED_BY (cs_hSocket) |
size_t nSendSize | GUARDED_BY (cs_vSend) |
Total size of all vSendMsg entries. More... | |
size_t nSendOffset | GUARDED_BY (cs_vSend) |
Offset inside the first vSendMsg already sent. More... | |
uint64_t nSendBytes | GUARDED_BY (cs_vSend) |
std::deque< std::vector< uint8_t > > 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 (m_subver_mutex) |
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 | IsAvalancheOutboundConnection () const |
bool | ExpectServicesFromConn () const |
Network | ConnectedThroughNetwork () const |
Get network the peer connected through. More... | |
std::optional< CPubKey > m_avalanche_pubkey | GUARDED_BY (cs_avalanche_pubkey) |
void | invsPolled (uint32_t count) |
The node was polled for count invs. More... | |
void | invsVoted (uint32_t count) |
The node voted for count invs. More... | |
void | updateAvailabilityScore (double decayFactor) |
The availability score is calculated using an exponentially weighted average. More... | |
double | getAvailabilityScore () const |
CNode (NodeId id, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, uint64_t nLocalExtraEntropyIn, const CAddress &addrBindIn, const std::string &addrNameIn, ConnectionType conn_type_in, bool inbound_onion) | |
~CNode () | |
CNode (const CNode &)=delete | |
CNode & | operator= (const CNode &)=delete |
void | PongReceived (std::chrono::microseconds ping_time) |
A ping-pong round trip has completed successfully. More... | |
NodeId | GetId () const |
uint64_t | GetLocalNonce () const |
uint64_t | GetLocalExtraEntropy () const |
int | GetRefCount () const |
bool | ReceiveMsgBytes (const Config &config, Span< const uint8_t > msg_bytes, bool &complete) EXCLUSIVE_LOCKS_REQUIRED(!cs_vRecv) |
Receive bytes from the buffer and deserialize them into messages. More... | |
void | SetCommonVersion (int greatest_common_version) |
int | GetCommonVersion () const |
CService | GetAddrLocal () const EXCLUSIVE_LOCKS_REQUIRED(!m_addr_local_mutex) |
void | SetAddrLocal (const CService &addrLocalIn) EXCLUSIVE_LOCKS_REQUIRED(!m_addr_local_mutex) |
May not be called more than once. More... | |
CNode * | AddRef () |
void | Release () |
void | CloseSocketDisconnect () EXCLUSIVE_LOCKS_REQUIRED(!cs_hSocket) |
void | copyStats (CNodeStats &stats) EXCLUSIVE_LOCKS_REQUIRED(!m_subver_mutex |
std::string | ConnectionTypeAsString () const |
Public Attributes | |
std::unique_ptr< TransportDeserializer > | m_deserializer |
std::unique_ptr< TransportSerializer > | m_serializer |
Mutex | cs_vSend |
Mutex | cs_hSocket |
Mutex | cs_vRecv |
RecursiveMutex | cs_vProcessMsg |
size_t | nProcessQueueSize {0} |
std::atomic< std::chrono::seconds > | m_last_send {0s} |
std::atomic< std::chrono::seconds > | m_last_recv {0s} |
const std::chrono::seconds | m_connected |
Unix epoch time at peer connection. More... | |
std::atomic< int64_t > | nTimeOffset {0} |
const CAddress | addr |
const CAddress | addrBind |
const std::string | m_addr_name |
const bool | m_inbound_onion |
Whether this peer is an inbound onion, i.e. More... | |
std::atomic< int > | nVersion {0} |
uint64_t | nRemoteHostNonce {0} |
uint64_t | nRemoteExtraEntropy {0} |
Mutex | m_subver_mutex |
cleanSubVer is a sanitized string of the user agent byte array we read from the wire. More... | |
bool | m_prefer_evict {false} |
std::atomic_bool | fSuccessfullyConnected {false} |
std::atomic_bool | fDisconnect {false} |
CSemaphoreGrant | grantOutbound |
std::atomic< int > | nRefCount {0} |
const uint64_t | nKeyedNetGroup |
std::atomic_bool | fPauseRecv {false} |
std::atomic_bool | fPauseSend {false} |
std::atomic< bool > | m_bip152_highbandwidth_to {false} |
std::atomic< bool > | m_bip152_highbandwidth_from {false} |
std::atomic_bool | m_has_all_wanted_services {false} |
Whether this peer provides all services that we want. More... | |
std::atomic_bool | m_relays_txs {false} |
Whether we should relay transactions to this peer. More... | |
std::atomic_bool | m_bloom_filter_loaded {false} |
Whether this peer has loaded a bloom filter. More... | |
std::atomic< bool > | m_avalanche_enabled {false} |
Mutex | cs_avalanche_pubkey |
std::chrono::seconds | m_nextGetAvaAddr {0} |
std::atomic< std::chrono::seconds > | m_avalanche_last_message_fault {0s} |
std::atomic< int > | m_avalanche_message_fault_counter {0} |
SteadyMilliseconds | m_last_poll {} |
std::atomic< std::chrono::seconds > | m_last_block_time {0s} |
UNIX epoch time of the last block received from this peer that we had not yet seen (e.g. More... | |
std::atomic< std::chrono::seconds > | m_last_tx_time {0s} |
UNIX epoch time of the last transaction received from this peer that we had not yet seen (e.g. More... | |
std::atomic< std::chrono::seconds > | m_last_proof_time {0s} |
UNIX epoch time of the last proof received from this peer that we had not yet seen (e.g. More... | |
std::atomic< std::chrono::microseconds > | m_last_ping_time {0us} |
Last measured round-trip time. More... | |
std::atomic< std::chrono::microseconds > | m_min_ping_time |
Lowest measured round-trip time. More... | |
void | !m_addr_local_mutex |
void | !cs_vSend |
void | !cs_vRecv |
Private Member Functions | |
CService addrLocal | GUARDED_BY (m_addr_local_mutex) |
mapMsgCmdSize mapSendBytesPerMsgCmd | GUARDED_BY (cs_vSend) |
mapMsgCmdSize mapRecvBytesPerMsgCmd | GUARDED_BY (cs_vRecv) |
Private Attributes | |
const NodeId | id |
const uint64_t | nLocalHostNonce |
const uint64_t | nLocalExtraEntropy |
const ConnectionType | m_conn_type |
std::atomic< int > | m_greatest_common_version {INIT_PROTO_VERSION} |
NetPermissionFlags | m_permissionFlags {NetPermissionFlags::None} |
std::list< CNetMessage > | vRecvMsg |
Mutex | m_addr_local_mutex |
std::atomic< uint64_t > | invCounters {0} |
The inventories polled and voted counters since last score computation, stored as a pair of uint32_t with the poll counter being the 32 lowest bits and the vote counter the 32 highest bits. More... | |
std::atomic< double > | availabilityScore {0.} |
The last computed score. More... | |
Friends | |
class | CConnman |
struct | ConnmanTestMsg |
CNode::CNode | ( | NodeId | id, |
SOCKET | hSocketIn, | ||
const CAddress & | addrIn, | ||
uint64_t | nKeyedNetGroupIn, | ||
uint64_t | nLocalHostNonceIn, | ||
uint64_t | nLocalExtraEntropyIn, | ||
const CAddress & | addrBindIn, | ||
const std::string & | addrNameIn, | ||
ConnectionType | conn_type_in, | ||
bool | inbound_onion | ||
) |
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.
Definition at line 615 of file net.cpp.
|
inline |
void CNode::copyStats | ( | CNodeStats & | stats | ) |
|
inline |
CService CNode::GetAddrLocal | ( | ) | const |
double CNode::getAvailabilityScore | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
std::optional< CPubKey > m_avalanche_pubkey CNode::GUARDED_BY | ( | cs_avalanche_pubkey | ) |
SOCKET hSocket CNode::GUARDED_BY | ( | cs_hSocket | ) |
std::list< CNetMessage > vProcessMsg CNode::GUARDED_BY | ( | cs_vProcessMsg | ) |
|
private |
|
inline |
|
inline |
std::deque< std::vector< uint8_t > > vSendMsg CNode::GUARDED_BY | ( | cs_vSend | ) |
|
private |
|
private |
|
inline |
|
inline |
void CNode::invsPolled | ( | uint32_t | count | ) |
void CNode::invsVoted | ( | uint32_t | count | ) |
|
inline |
|
inline |
|
inline |
bool CNode::ReceiveMsgBytes | ( | const Config & | config, |
Span< const uint8_t > | msg_bytes, | ||
bool & | complete | ||
) |
Receive bytes from the buffer and deserialize them into messages.
[in] | msg_bytes | The raw data |
[out] | complete | Set True if at least one message has been deserialized and is ready to be processed |
Definition at line 667 of file net.cpp.
void CNode::SetAddrLocal | ( | const CService & | addrLocalIn | ) |
|
inline |
void CNode::updateAvailabilityScore | ( | double | decayFactor | ) |
The availability score is calculated using an exponentially weighted average.
This has several interesting properties:
This is expected to be called at a fixed interval of AVALANCHE_STATISTICS_REFRESH_PERIOD.
|
private |
RecursiveMutex CNode::cs_vProcessMsg |
CSemaphoreGrant CNode::grantOutbound |
|
private |
std::atomic<std::chrono::seconds> CNode::m_avalanche_last_message_fault {0s} |
std::atomic_bool CNode::m_bloom_filter_loaded {false} |
|
private |
const std::chrono::seconds CNode::m_connected |
std::unique_ptr<TransportDeserializer> CNode::m_deserializer |
|
private |
std::atomic_bool CNode::m_has_all_wanted_services {false} |
const bool CNode::m_inbound_onion |
std::atomic<std::chrono::seconds> CNode::m_last_block_time {0s} |
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<std::chrono::microseconds> CNode::m_last_ping_time {0us} |
SteadyMilliseconds CNode::m_last_poll {} |
std::atomic<std::chrono::seconds> CNode::m_last_proof_time {0s} |
UNIX epoch time of the last proof received from this peer that we had not yet seen (e.g.
not already received from another peer) and that was accepted into our proof pool. Used as an inbound peer eviction criterium in CConnman::AttemptToEvictConnection.
std::atomic<std::chrono::seconds> CNode::m_last_tx_time {0s} |
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.
std::atomic<std::chrono::microseconds> CNode::m_min_ping_time |
Lowest measured round-trip time.
Used as an inbound peer eviction criterium in CConnman::AttemptToEvictConnection.
|
private |
std::atomic_bool CNode::m_relays_txs {false} |
std::unique_ptr<TransportSerializer> CNode::m_serializer |
Mutex CNode::m_subver_mutex |
|
private |