Bitcoin ABC 0.30.5
P2P Digital Currency
Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
avalanche::PeerManager Class Reference

#include <peermanager.h>

Collaboration diagram for avalanche::PeerManager:
[legend]

Public Types

enum class  RegistrationMode { DEFAULT , FORCE_ACCEPT }
 Registration mode. More...
 
enum class  RejectionMode { DEFAULT , INVALIDATE }
 Rejection mode. More...
 

Public Member Functions

 PeerManager (const Amount &stakeUtxoDustThresholdIn, ChainstateManager &chainmanIn, const ProofRef &localProofIn=ProofRef())
 
bool addNode (NodeId nodeid, const ProofId &proofid)
 Node API. More...
 
bool removeNode (NodeId nodeid)
 
size_t getNodeCount () const
 
size_t getPendingNodeCount () const
 
bool updateNextRequestTime (NodeId nodeid, SteadyMilliseconds timeout)
 
bool latchAvaproofsSent (NodeId nodeid)
 Flag that a node did send its compact proofs. More...
 
NodeId selectNode ()
 
bool shouldRequestMoreNodes ()
 Returns true if we encountered a lack of node since the last call. More...
 
template<typename Callable >
bool forNode (NodeId nodeid, Callable &&func) const
 
template<typename Callable >
void forEachNode (const Peer &peer, Callable &&func) const
 
bool updateNextPossibleConflictTime (PeerId peerid, const std::chrono::seconds &nextTime)
 Proof and Peer related API. More...
 
bool setFinalized (PeerId peerid)
 Latch on that this peer has a finalized proof. More...
 
bool registerProof (const ProofRef &proof, ProofRegistrationState &registrationState, RegistrationMode mode=RegistrationMode::DEFAULT)
 
bool registerProof (const ProofRef &proof, RegistrationMode mode=RegistrationMode::DEFAULT)
 
bool rejectProof (const ProofId &proofid, RejectionMode mode=RejectionMode::DEFAULT)
 
bool exists (const ProofId &proofid) const
 Return true if the (valid) proof exists, but only for non-dangling proofs. More...
 
void cleanupDanglingProofs (std::unordered_set< ProofRef, SaltedProofHasher > &registeredProofs)
 
template<typename Callable >
bool forPeer (const ProofId &proofid, Callable &&func) const
 
template<typename Callable >
void forEachPeer (Callable &&func) const
 
std::unordered_set< ProofRef, SaltedProofHasherupdatedBlockTip ()
 Update the peer set when a new block is connected. More...
 
void addUnbroadcastProof (const ProofId &proofid)
 Proof broadcast API. More...
 
void removeUnbroadcastProof (const ProofId &proofid)
 
auto getUnbroadcastProofs () const
 
uint32_t getTotalPeersScore () const
 
uint32_t getConnectedPeersScore () const
 
bool saveRemoteProof (const ProofId &proofid, const NodeId nodeid, const bool present)
 
std::vector< RemoteProofgetRemoteProofs (const NodeId nodeid) const
 
bool isRemoteProof (const ProofId &proofid) const
 
bool setFlaky (const ProofId &proofid)
 
bool unsetFlaky (const ProofId &proofid)
 
template<typename Callable >
void forEachFlakyProof (Callable &&func) const
 
template<typename Callable >
void updateAvailabilityScores (const double decayFactor, Callable &&getNodeAvailabilityScore)
 
bool removePeer (const PeerId peerid)
 Remove an existing peer. More...
 
PeerId selectPeer () const
 Randomly select a peer to poll. More...
 
uint64_t compact ()
 Trigger maintenance of internal data structures. More...
 
bool verify () const
 Perform consistency check on internal data structures. More...
 
uint64_t getSlotCount () const
 
uint64_t getFragmentation () const
 
const ProofPoolgetValidProofPool () const
 
const ProofPoolgetConflictingProofPool () const
 
const ProofPoolgetImmatureProofPool () const
 
ProofRef getProof (const ProofId &proofid) const
 
bool isBoundToPeer (const ProofId &proofid) const
 
bool isImmature (const ProofId &proofid) const
 
bool isInConflictingPool (const ProofId &proofid) const
 
bool isDangling (const ProofId &proofid) const
 
void setInvalid (const ProofId &proofid)
 
bool isInvalid (const ProofId &proofid) const
 
void clearAllInvalid ()
 
const ProofRadixTreegetShareableProofsSnapshot () const
 
const AmountgetStakeUtxoDustThreshold () const
 
bool selectStakingRewardWinner (const CBlockIndex *pprev, std::vector< std::pair< ProofId, CScript > > &winners)
 Deterministically select a list of payout scripts based on the proof set and the previous block hash. More...
 
bool dumpPeersToFile (const fs::path &dumpPath) const
 
bool loadPeersFromFile (const fs::path &dumpPath, std::unordered_set< ProofRef, SaltedProofHasher > &registeredProofs)
 

Static Public Attributes

static constexpr size_t MAX_REMOTE_PROOFS {100}
 

Private Types

using PeerSet = boost::multi_index_container< Peer, bmi::indexed_by< bmi::hashed_unique< bmi::member< Peer, PeerId, &Peer::peerid > >, bmi::hashed_unique< bmi::tag< by_proofid >, proof_index, SaltedProofIdHasher >, bmi::ordered_non_unique< bmi::tag< by_score >, score_index, std::greater< uint32_t > > > >
 Several nodes can make an avalanche peer. More...
 
using ProofRadixTree = RadixTree< const Proof, ProofRadixTreeAdapter >
 
using NodeSet = boost::multi_index_container< Node, bmi::indexed_by< bmi::hashed_unique< bmi::member< Node, NodeId, &Node::nodeid > >, bmi::ordered_non_unique< bmi::tag< next_request_time >, bmi::composite_key< Node, bmi::member< Node, PeerId, &Node::peerid >, bmi::member< Node, SteadyMilliseconds, &Node::nextRequestTime > > > > >
 
using PendingNodeSet = boost::multi_index_container< PendingNode, bmi::indexed_by< bmi::hashed_non_unique< bmi::tag< by_proofid >, bmi::member< PendingNode, ProofId, &PendingNode::proofid >, SaltedProofIdHasher >, bmi::hashed_unique< bmi::tag< by_nodeid >, bmi::member< PendingNode, NodeId, &PendingNode::nodeid > > > >
 
using RemoteProofSet = boost::multi_index_container< RemoteProof, bmi::indexed_by< bmi::hashed_unique< bmi::composite_key< RemoteProof, bmi::member< RemoteProof, ProofId, &RemoteProof::proofid >, bmi::member< RemoteProof, NodeId, &RemoteProof::nodeid > >, bmi::composite_key_hash< SaltedProofIdHasher, boost::hash< NodeId > > >, bmi::hashed_non_unique< bmi::tag< by_proofid >, bmi::member< RemoteProof, ProofId, &RemoteProof::proofid >, SaltedProofIdHasher >, bmi::hashed_non_unique< bmi::tag< by_nodeid >, bmi::member< RemoteProof, NodeId, &RemoteProof::nodeid > >, bmi::ordered_non_unique< bmi::tag< by_lastUpdate >, bmi::composite_key< RemoteProof, bmi::member< RemoteProof, NodeId, &RemoteProof::nodeid >, bmi::member< RemoteProof, std::chrono::seconds, &RemoteProof::lastUpdate > > > > >
 

Private Member Functions

template<typename ProofContainer >
void moveToConflictingPool (const ProofContainer &proofs)
 
bool addOrUpdateNode (const PeerSet::iterator &it, NodeId nodeid)
 
bool addNodeToPeer (const PeerSet::iterator &it)
 
bool removeNodeFromPeer (const PeerSet::iterator &it, uint32_t count=1)
 
std::optional< bool > getRemotePresenceStatus (const ProofId &proofid) const
 Get the presence remote status of a proof. More...
 
bool isFlaky (const ProofId &proofid) const
 

Private Attributes

std::vector< Slotslots
 
uint64_t slotCount = 0
 
uint64_t fragmentation = 0
 
PeerId nextPeerId = 0
 
PeerSet peers
 
ProofPool validProofPool
 
ProofPool conflictingProofPool
 
ProofPool immatureProofPool
 
ProofPool danglingProofPool
 
ProofRadixTree shareableProofs
 
NodeSet nodes
 
std::atomic< bool > needMoreNodes {false}
 Flag indicating that we failed to select a node and need to expand our node set. More...
 
PendingNodeSet pendingNodes
 
ProofIdSet m_unbroadcast_proofids
 Track proof ids to broadcast. More...
 
uint32_t totalPeersScore = 0
 Quorum management. More...
 
uint32_t connectedPeersScore = 0
 
Amount stakeUtxoDustThreshold
 
ChainstateManagerchainman
 
ProofRef localProof
 
RemoteProofSet remoteProofs
 Remember which node sent which proof so we have an image of the proof set of our peers. More...
 
CRollingBloomFilter invalidProofs {100000, 0.000001}
 Filter for proofs that are consensus-invalid or were recently invalidated by avalanche (finalized rejection). More...
 
std::unordered_set< ProofId, SaltedProofIdHashermanualFlakyProofids
 

Static Private Attributes

static constexpr int SELECT_PEER_MAX_RETRY = 3
 
static constexpr int SELECT_NODE_MAX_RETRY = 3
 

Friends

struct ::avalanche::TestPeerManager
 

Detailed Description

Definition at line 162 of file peermanager.h.

Member Typedef Documentation

◆ NodeSet

using avalanche::PeerManager::NodeSet = boost::multi_index_container< Node, bmi::indexed_by< bmi::hashed_unique<bmi::member<Node, NodeId, &Node::nodeid> >, bmi::ordered_non_unique< bmi::tag<next_request_time>, bmi::composite_key< Node, bmi::member<Node, PeerId, &Node::peerid>, bmi::member<Node, SteadyMilliseconds, &Node::nextRequestTime> >> >>
private

Definition at line 193 of file peermanager.h.

◆ PeerSet

using avalanche::PeerManager::PeerSet = boost::multi_index_container< Peer, bmi::indexed_by< bmi::hashed_unique<bmi::member<Peer, PeerId, &Peer::peerid> >, bmi::hashed_unique<bmi::tag<by_proofid>, proof_index, SaltedProofIdHasher>, bmi::ordered_non_unique<bmi::tag<by_score>, score_index, std::greater<uint32_t> >> >
private

Several nodes can make an avalanche peer.

In this case, all nodes are considered interchangeable parts of the same peer.

Definition at line 171 of file peermanager.h.

◆ PendingNodeSet

using avalanche::PeerManager::PendingNodeSet = boost::multi_index_container< PendingNode, bmi::indexed_by< bmi::hashed_non_unique< bmi::tag<by_proofid>, bmi::member<PendingNode, ProofId, &PendingNode::proofid>, SaltedProofIdHasher>, bmi::hashed_unique< bmi::tag<by_nodeid>, bmi::member<PendingNode, NodeId, &PendingNode::nodeid> >> >
private

Definition at line 213 of file peermanager.h.

◆ ProofRadixTree

Definition at line 190 of file peermanager.h.

◆ RemoteProofSet

using avalanche::PeerManager::RemoteProofSet = boost::multi_index_container< RemoteProof, bmi::indexed_by< bmi::hashed_unique< bmi::composite_key< RemoteProof, bmi::member<RemoteProof, ProofId, &RemoteProof::proofid>, bmi::member<RemoteProof, NodeId, &RemoteProof::nodeid> >, bmi::composite_key_hash<SaltedProofIdHasher, boost::hash<NodeId> >>, bmi::hashed_non_unique< bmi::tag<by_proofid>, bmi::member<RemoteProof, ProofId, &RemoteProof::proofid>, SaltedProofIdHasher>, bmi::hashed_non_unique< bmi::tag<by_nodeid>, bmi::member<RemoteProof, NodeId, &RemoteProof::nodeid> >, bmi::ordered_non_unique< bmi::tag<by_lastUpdate>, bmi::composite_key< RemoteProof, bmi::member<RemoteProof, NodeId, &RemoteProof::nodeid>, bmi::member<RemoteProof, std::chrono::seconds, &RemoteProof::lastUpdate> >> >>
private

Definition at line 249 of file peermanager.h.

Member Enumeration Documentation

◆ RegistrationMode

Registration mode.

  • DEFAULT: Default policy, register only if the proof is unknown and has no conflict.
  • FORCE_ACCEPT: Turn a valid proof into a peer even if it has conflicts and is not the best candidate.
Enumerator
DEFAULT 
FORCE_ACCEPT 

Definition at line 371 of file peermanager.h.

◆ RejectionMode

Rejection mode.

  • DEFAULT: Default policy, reject a proof and attempt to keep it in the conflicting pool if possible.
  • INVALIDATE: Reject a proof by removing it from any of the pool.

In any case if a peer is rejected, it attempts to pull the conflicting proofs back.

Enumerator
DEFAULT 
INVALIDATE 

Definition at line 394 of file peermanager.h.

Constructor & Destructor Documentation

◆ PeerManager()

avalanche::PeerManager::PeerManager ( const Amount stakeUtxoDustThresholdIn,
ChainstateManager chainmanIn,
const ProofRef localProofIn = ProofRef() 
)
inline

Definition at line 302 of file peermanager.h.

Member Function Documentation

◆ addNode()

bool PeerManager::addNode ( NodeId  nodeid,
const ProofId proofid 
)

Node API.

Definition at line 31 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addNodeToPeer()

bool PeerManager::addNodeToPeer ( const PeerSet::iterator &  it)
private

Definition at line 87 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOrUpdateNode()

bool PeerManager::addOrUpdateNode ( const PeerSet::iterator &  it,
NodeId  nodeid 
)
private

Definition at line 46 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addUnbroadcastProof()

void PeerManager::addUnbroadcastProof ( const ProofId proofid)

Proof broadcast API.

Definition at line 984 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanupDanglingProofs()

void PeerManager::cleanupDanglingProofs ( std::unordered_set< ProofRef, SaltedProofHasher > &  registeredProofs)

Definition at line 474 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearAllInvalid()

void PeerManager::clearAllInvalid ( )

Definition at line 653 of file peermanager.cpp.

Here is the call graph for this function:

◆ compact()

uint64_t PeerManager::compact ( )

Trigger maintenance of internal data structures.

Returns how much slot space was saved after compaction.

Definition at line 761 of file peermanager.cpp.

Here is the caller graph for this function:

◆ dumpPeersToFile()

bool PeerManager::dumpPeersToFile ( const fs::path dumpPath) const

Definition at line 1285 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exists()

bool avalanche::PeerManager::exists ( const ProofId proofid) const
inline

Return true if the (valid) proof exists, but only for non-dangling proofs.

Definition at line 406 of file peermanager.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ forEachFlakyProof()

template<typename Callable >
void avalanche::PeerManager::forEachFlakyProof ( Callable &&  func) const
inline

Definition at line 451 of file peermanager.h.

Here is the caller graph for this function:

◆ forEachNode()

template<typename Callable >
void avalanche::PeerManager::forEachNode ( const Peer peer,
Callable &&  func 
) const
inline

Definition at line 340 of file peermanager.h.

Here is the caller graph for this function:

◆ forEachPeer()

template<typename Callable >
void avalanche::PeerManager::forEachPeer ( Callable &&  func) const
inline

Definition at line 420 of file peermanager.h.

Here is the caller graph for this function:

◆ forNode()

template<typename Callable >
bool avalanche::PeerManager::forNode ( NodeId  nodeid,
Callable &&  func 
) const
inline

Definition at line 334 of file peermanager.h.

Here is the caller graph for this function:

◆ forPeer()

template<typename Callable >
bool avalanche::PeerManager::forPeer ( const ProofId proofid,
Callable &&  func 
) const
inline

Definition at line 414 of file peermanager.h.

Here is the caller graph for this function:

◆ getConflictingProofPool()

const ProofPool & avalanche::PeerManager::getConflictingProofPool ( ) const
inline

Definition at line 506 of file peermanager.h.

Here is the caller graph for this function:

◆ getConnectedPeersScore()

uint32_t avalanche::PeerManager::getConnectedPeersScore ( ) const
inline

Definition at line 442 of file peermanager.h.

Here is the caller graph for this function:

◆ getFragmentation()

uint64_t avalanche::PeerManager::getFragmentation ( ) const
inline

Definition at line 503 of file peermanager.h.

Here is the caller graph for this function:

◆ getImmatureProofPool()

const ProofPool & avalanche::PeerManager::getImmatureProofPool ( ) const
inline

Definition at line 509 of file peermanager.h.

Here is the caller graph for this function:

◆ getNodeCount()

size_t avalanche::PeerManager::getNodeCount ( ) const
inline

Definition at line 313 of file peermanager.h.

Here is the caller graph for this function:

◆ getPendingNodeCount()

size_t avalanche::PeerManager::getPendingNodeCount ( ) const
inline

Definition at line 314 of file peermanager.h.

Here is the caller graph for this function:

◆ getProof()

ProofRef PeerManager::getProof ( const ProofId proofid) const

Definition at line 609 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRemotePresenceStatus()

std::optional< bool > PeerManager::getRemotePresenceStatus ( const ProofId proofid) const
private

Get the presence remote status of a proof.

Parameters
proofidThe target proof id
Returns
true if it's likely present, false if likely missing, nullopt if uncertain.

Definition at line 1199 of file peermanager.cpp.

Here is the caller graph for this function:

◆ getRemoteProofs()

std::vector< RemoteProof > PeerManager::getRemoteProofs ( const NodeId  nodeid) const

Definition at line 686 of file peermanager.cpp.

Here is the caller graph for this function:

◆ getShareableProofsSnapshot()

const ProofRadixTree & avalanche::PeerManager::getShareableProofsSnapshot ( ) const
inline

Definition at line 521 of file peermanager.h.

Here is the caller graph for this function:

◆ getSlotCount()

uint64_t avalanche::PeerManager::getSlotCount ( ) const
inline

Definition at line 502 of file peermanager.h.

Here is the caller graph for this function:

◆ getStakeUtxoDustThreshold()

const Amount & avalanche::PeerManager::getStakeUtxoDustThreshold ( ) const
inline

Definition at line 525 of file peermanager.h.

Here is the caller graph for this function:

◆ getTotalPeersScore()

uint32_t avalanche::PeerManager::getTotalPeersScore ( ) const
inline

Definition at line 441 of file peermanager.h.

Here is the caller graph for this function:

◆ getUnbroadcastProofs()

auto avalanche::PeerManager::getUnbroadcastProofs ( ) const
inline

Definition at line 436 of file peermanager.h.

◆ getValidProofPool()

const ProofPool & avalanche::PeerManager::getValidProofPool ( ) const
inline

Definition at line 505 of file peermanager.h.

Here is the caller graph for this function:

◆ isBoundToPeer()

bool PeerManager::isBoundToPeer ( const ProofId proofid) const

Definition at line 628 of file peermanager.cpp.

Here is the caller graph for this function:

◆ isDangling()

bool PeerManager::isDangling ( const ProofId proofid) const

Definition at line 641 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFlaky()

bool PeerManager::isFlaky ( const ProofId proofid) const
private

Definition at line 1135 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isImmature()

bool PeerManager::isImmature ( const ProofId proofid) const

Definition at line 633 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInConflictingPool()

bool PeerManager::isInConflictingPool ( const ProofId proofid) const

Definition at line 637 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInvalid()

bool PeerManager::isInvalid ( const ProofId proofid) const

Definition at line 649 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRemoteProof()

bool PeerManager::isRemoteProof ( const ProofId proofid) const

Definition at line 699 of file peermanager.cpp.

Here is the caller graph for this function:

◆ latchAvaproofsSent()

bool PeerManager::latchAvaproofsSent ( NodeId  nodeid)

Flag that a node did send its compact proofs.

Returns
True if the flag changed state, i;e. if this is the first time the message is accounted for this node.

Definition at line 192 of file peermanager.cpp.

Here is the caller graph for this function:

◆ loadPeersFromFile()

bool PeerManager::loadPeersFromFile ( const fs::path dumpPath,
std::unordered_set< ProofRef, SaltedProofHasher > &  registeredProofs 
)

Definition at line 1326 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ moveToConflictingPool()

template<typename ProofContainer >
void PeerManager::moveToConflictingPool ( const ProofContainer &  proofs)
private

Definition at line 236 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerProof() [1/2]

bool PeerManager::registerProof ( const ProofRef proof,
ProofRegistrationState registrationState,
RegistrationMode  mode = RegistrationMode::DEFAULT 
)

Definition at line 248 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerProof() [2/2]

bool avalanche::PeerManager::registerProof ( const ProofRef proof,
RegistrationMode  mode = RegistrationMode::DEFAULT 
)
inline

Definition at line 379 of file peermanager.h.

Here is the call graph for this function:

◆ rejectProof()

bool PeerManager::rejectProof ( const ProofId proofid,
RejectionMode  mode = RejectionMode::DEFAULT 
)

Definition at line 419 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeNode()

bool PeerManager::removeNode ( NodeId  nodeid)

Definition at line 107 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeNodeFromPeer()

bool PeerManager::removeNodeFromPeer ( const PeerSet::iterator &  it,
uint32_t  count = 1 
)
private

Definition at line 133 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removePeer()

bool PeerManager::removePeer ( const PeerId  peerid)

Remove an existing peer.

Definition at line 704 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeUnbroadcastProof()

void PeerManager::removeUnbroadcastProof ( const ProofId proofid)

Definition at line 991 of file peermanager.cpp.

◆ saveRemoteProof()

bool PeerManager::saveRemoteProof ( const ProofId proofid,
const NodeId  nodeid,
const bool  present 
)

Definition at line 657 of file peermanager.cpp.

Here is the caller graph for this function:

◆ selectNode()

NodeId PeerManager::selectNode ( )

Definition at line 528 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectPeer()

PeerId PeerManager::selectPeer ( ) const

Randomly select a peer to poll.

Definition at line 745 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectStakingRewardWinner()

bool PeerManager::selectStakingRewardWinner ( const CBlockIndex pprev,
std::vector< std::pair< ProofId, CScript > > &  winners 
)

Deterministically select a list of payout scripts based on the proof set and the previous block hash.

Definition at line 995 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFinalized()

bool PeerManager::setFinalized ( PeerId  peerid)

Latch on that this peer has a finalized proof.

Definition at line 223 of file peermanager.cpp.

Here is the caller graph for this function:

◆ setFlaky()

bool PeerManager::setFlaky ( const ProofId proofid)

Definition at line 1127 of file peermanager.cpp.

◆ setInvalid()

void PeerManager::setInvalid ( const ProofId proofid)

Definition at line 645 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shouldRequestMoreNodes()

bool avalanche::PeerManager::shouldRequestMoreNodes ( )
inline

Returns true if we encountered a lack of node since the last call.

Definition at line 331 of file peermanager.h.

Here is the caller graph for this function:

◆ unsetFlaky()

bool PeerManager::unsetFlaky ( const ProofId proofid)

Definition at line 1131 of file peermanager.cpp.

Here is the caller graph for this function:

◆ updateAvailabilityScores()

template<typename Callable >
void avalanche::PeerManager::updateAvailabilityScores ( const double  decayFactor,
Callable &&  getNodeAvailabilityScore 
)
inline

Definition at line 458 of file peermanager.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updatedBlockTip()

std::unordered_set< ProofRef, SaltedProofHasher > PeerManager::updatedBlockTip ( )

Update the peer set when a new block is connected.

Definition at line 554 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateNextPossibleConflictTime()

bool PeerManager::updateNextPossibleConflictTime ( PeerId  peerid,
const std::chrono::seconds &  nextTime 
)

Proof and Peer related API.

Update the time before which a proof is not allowed to have conflicting UTXO with this peer's proof.

Definition at line 206 of file peermanager.cpp.

Here is the caller graph for this function:

◆ updateNextRequestTime()

bool PeerManager::updateNextRequestTime ( NodeId  nodeid,
SteadyMilliseconds  timeout 
)

Definition at line 182 of file peermanager.cpp.

Here is the caller graph for this function:

◆ verify()

bool PeerManager::verify ( ) const

Perform consistency check on internal data structures.

Definition at line 793 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ::avalanche::TestPeerManager

friend struct ::avalanche::TestPeerManager
friend

Definition at line 561 of file peermanager.h.

Member Data Documentation

◆ chainman

ChainstateManager& avalanche::PeerManager::chainman
private

Definition at line 243 of file peermanager.h.

◆ conflictingProofPool

ProofPool avalanche::PeerManager::conflictingProofPool
private

Definition at line 186 of file peermanager.h.

◆ connectedPeersScore

uint32_t avalanche::PeerManager::connectedPeersScore = 0
private

Definition at line 239 of file peermanager.h.

◆ danglingProofPool

ProofPool avalanche::PeerManager::danglingProofPool
private

Definition at line 188 of file peermanager.h.

◆ fragmentation

uint64_t avalanche::PeerManager::fragmentation = 0
private

Definition at line 165 of file peermanager.h.

◆ immatureProofPool

ProofPool avalanche::PeerManager::immatureProofPool
private

Definition at line 187 of file peermanager.h.

◆ invalidProofs

CRollingBloomFilter avalanche::PeerManager::invalidProofs {100000, 0.000001}
private

Filter for proofs that are consensus-invalid or were recently invalidated by avalanche (finalized rejection).

These are not rerequested until they are rolled out of the filter.

Without this filter we'd be re-requesting proofs from each of our peers, increasing bandwidth consumption considerably.

Decreasing the false positive rate is fairly cheap, so we pick one in a million to make it highly unlikely for users to have issues with this filter.

Definition at line 295 of file peermanager.h.

◆ localProof

ProofRef avalanche::PeerManager::localProof
private

Definition at line 245 of file peermanager.h.

◆ m_unbroadcast_proofids

ProofIdSet avalanche::PeerManager::m_unbroadcast_proofids
private

Track proof ids to broadcast.

Definition at line 233 of file peermanager.h.

◆ manualFlakyProofids

std::unordered_set<ProofId, SaltedProofIdHasher> avalanche::PeerManager::manualFlakyProofids
private

Definition at line 297 of file peermanager.h.

◆ MAX_REMOTE_PROOFS

constexpr size_t avalanche::PeerManager::MAX_REMOTE_PROOFS {100}
staticconstexpr

Definition at line 300 of file peermanager.h.

◆ needMoreNodes

std::atomic<bool> avalanche::PeerManager::needMoreNodes {false}
private

Flag indicating that we failed to select a node and need to expand our node set.

Definition at line 211 of file peermanager.h.

◆ nextPeerId

PeerId avalanche::PeerManager::nextPeerId = 0
private

Definition at line 182 of file peermanager.h.

◆ nodes

NodeSet avalanche::PeerManager::nodes
private

Definition at line 205 of file peermanager.h.

◆ peers

PeerSet avalanche::PeerManager::peers
private

Definition at line 183 of file peermanager.h.

◆ pendingNodes

PendingNodeSet avalanche::PeerManager::pendingNodes
private

Definition at line 225 of file peermanager.h.

◆ remoteProofs

RemoteProofSet avalanche::PeerManager::remoteProofs
private

Remember which node sent which proof so we have an image of the proof set of our peers.

Definition at line 281 of file peermanager.h.

◆ SELECT_NODE_MAX_RETRY

constexpr int avalanche::PeerManager::SELECT_NODE_MAX_RETRY = 3
staticconstexprprivate

Definition at line 228 of file peermanager.h.

◆ SELECT_PEER_MAX_RETRY

constexpr int avalanche::PeerManager::SELECT_PEER_MAX_RETRY = 3
staticconstexprprivate

Definition at line 227 of file peermanager.h.

◆ shareableProofs

ProofRadixTree avalanche::PeerManager::shareableProofs
private

Definition at line 191 of file peermanager.h.

◆ slotCount

uint64_t avalanche::PeerManager::slotCount = 0
private

Definition at line 164 of file peermanager.h.

◆ slots

std::vector<Slot> avalanche::PeerManager::slots
private

Definition at line 163 of file peermanager.h.

◆ stakeUtxoDustThreshold

Amount avalanche::PeerManager::stakeUtxoDustThreshold
private

Definition at line 241 of file peermanager.h.

◆ totalPeersScore

uint32_t avalanche::PeerManager::totalPeersScore = 0
private

Quorum management.

Definition at line 238 of file peermanager.h.

◆ validProofPool

ProofPool avalanche::PeerManager::validProofPool
private

Definition at line 185 of file peermanager.h.


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