Bitcoin ABC  0.24.7
P2P Digital Currency
Public Member Functions | Public Attributes | Private Attributes | List of all members
CNode::AvalancheState Class Reference

#include <net.h>

Collaboration diagram for CNode::AvalancheState:
[legend]

Public Member Functions

 AvalancheState ()
 
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 ()
 The availability score is calculated using an exponentially weighted average. More...
 
double getAvailabilityScore () const
 

Public Attributes

CPubKey pubkey
 

Private Attributes

std::atomic< uint64_t > invCounters
 The inventories polled and voted couters 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
 The last computed score. More...
 
Mutex cs_statistics
 Protect the sequence of operations required for updating the statistics. More...
 

Detailed Description

Definition at line 1141 of file net.h.

Constructor & Destructor Documentation

◆ AvalancheState()

CNode::AvalancheState::AvalancheState ( )
inline

Definition at line 1161 of file net.h.

Member Function Documentation

◆ getAvailabilityScore()

double CNode::AvalancheState::getAvailabilityScore ( ) const

Definition at line 3272 of file net.cpp.

◆ invsPolled()

void CNode::AvalancheState::invsPolled ( uint32_t  count)

The node was polled for count invs.

Definition at line 3250 of file net.cpp.

◆ invsVoted()

void CNode::AvalancheState::invsVoted ( uint32_t  count)

The node voted for count invs.

Definition at line 3254 of file net.cpp.

◆ updateAvailabilityScore()

void CNode::AvalancheState::updateAvailabilityScore ( )

The availability score is calculated using an exponentially weighted average.

This has several interesting properties:

  • The most recent polls/responses have more weight than the previous ones. A node that recently stopped answering will see its ratio decrease quickly.
  • This is a low-pass filter, so it causes delay. This means that a node needs to have a track record for the ratio to be high. A node that has been little requested will have a lower ratio than a node that failed to answer a few polls but answered a lot of them.
  • It is cheap to compute.

This is expected to be called at a fixed interval of AVALANCHE_STATISTICS_REFRESH_PERIOD.

Definition at line 3258 of file net.cpp.

Member Data Documentation

◆ availabilityScore

std::atomic<double> CNode::AvalancheState::availabilityScore
private

The last computed score.

Definition at line 1150 of file net.h.

◆ cs_statistics

Mutex CNode::AvalancheState::cs_statistics
private

Protect the sequence of operations required for updating the statistics.

Definition at line 1156 of file net.h.

◆ invCounters

std::atomic<uint64_t> CNode::AvalancheState::invCounters
private

The inventories polled and voted couters 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.

Definition at line 1147 of file net.h.

◆ pubkey

CPubKey CNode::AvalancheState::pubkey

Definition at line 1159 of file net.h.


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