Bitcoin ABC 0.30.7
P2P Digital Currency
Public Types | Public Member Functions | Static Private Member Functions | Friends | List of all members
InvRequestTrackerImplInterface Class Referenceabstract

Data structure to keep track of, and schedule, inventory downloads from peers. More...

#include <invrequest.h>

Inheritance diagram for InvRequestTrackerImplInterface:
[legend]

Public Types

using ClearExpiredFun = const std::function< void()> &
 
using EmplaceExpiredFun = const std::function< void(const NodeId &, const uint256 &)> &
 

Public Member Functions

virtual ~InvRequestTrackerImplInterface ()=default
 
virtual void ReceivedInv (NodeId peer, const uint256 &invid, bool preferred, std::chrono::microseconds reqtime)=0
 
virtual void DisconnectedPeer (NodeId peer)=0
 
virtual void ForgetInvId (const uint256 &invid)=0
 
virtual std::vector< uint256GetRequestable (NodeId peer, std::chrono::microseconds now, ClearExpiredFun clearExpired, EmplaceExpiredFun emplaceExpired)=0
 
virtual void RequestedData (NodeId peer, const uint256 &invid, std::chrono::microseconds expiry)=0
 
virtual void ReceivedResponse (NodeId peer, const uint256 &invid)=0
 
virtual size_t CountInFlight (NodeId peer) const =0
 
virtual size_t CountCandidates (NodeId peer) const =0
 
virtual size_t Count (NodeId peer) const =0
 
virtual size_t Size () const =0
 
virtual uint64_t ComputePriority (const uint256 &invid, NodeId peer, bool preferred) const =0
 
virtual void SanityCheck () const =0
 
virtual void PostGetRequestableSanityCheck (std::chrono::microseconds now) const =0
 

Static Private Member Functions

static std::unique_ptr< InvRequestTrackerImplInterfaceBuildImpl (bool deterministic)
 

Friends

template<class InvId >
class InvRequestTracker
 

Detailed Description

Data structure to keep track of, and schedule, inventory downloads from peers.

=== Specification ===

We keep track of which peers have announced which inventories, and use that to determine which requests should go to which peer, when, and in what order.

The following information is tracked per peer/inv combination ("announcement"):

Transaction requests are then assigned to peers, following these rules:

Together these rules strike a balance between being fast in non-adverserial conditions and minimizing susceptibility to censorship attacks. An attacker that races the network:

Complexity:

Definition at line 121 of file invrequest.h.

Member Typedef Documentation

◆ ClearExpiredFun

using InvRequestTrackerImplInterface::ClearExpiredFun = const std::function<void()> &

Definition at line 131 of file invrequest.h.

◆ EmplaceExpiredFun

using InvRequestTrackerImplInterface::EmplaceExpiredFun = const std::function<void(const NodeId &, const uint256 &)> &

Definition at line 132 of file invrequest.h.

Constructor & Destructor Documentation

◆ ~InvRequestTrackerImplInterface()

virtual InvRequestTrackerImplInterface::~InvRequestTrackerImplInterface ( )
virtualdefault

Member Function Documentation

◆ BuildImpl()

std::unique_ptr< InvRequestTrackerImplInterface > InvRequestTrackerImplInterface::BuildImpl ( bool  deterministic)
staticprivate

Definition at line 863 of file invrequest.cpp.

◆ ComputePriority()

virtual uint64_t InvRequestTrackerImplInterface::ComputePriority ( const uint256 invid,
NodeId  peer,
bool  preferred 
) const
pure virtual

Implemented in InvRequestTrackerImpl.

◆ Count()

virtual size_t InvRequestTrackerImplInterface::Count ( NodeId  peer) const
pure virtual

Implemented in InvRequestTrackerImpl.

◆ CountCandidates()

virtual size_t InvRequestTrackerImplInterface::CountCandidates ( NodeId  peer) const
pure virtual

Implemented in InvRequestTrackerImpl.

◆ CountInFlight()

virtual size_t InvRequestTrackerImplInterface::CountInFlight ( NodeId  peer) const
pure virtual

Implemented in InvRequestTrackerImpl.

◆ DisconnectedPeer()

virtual void InvRequestTrackerImplInterface::DisconnectedPeer ( NodeId  peer)
pure virtual

Implemented in InvRequestTrackerImpl.

◆ ForgetInvId()

virtual void InvRequestTrackerImplInterface::ForgetInvId ( const uint256 invid)
pure virtual

Implemented in InvRequestTrackerImpl.

◆ GetRequestable()

virtual std::vector< uint256 > InvRequestTrackerImplInterface::GetRequestable ( NodeId  peer,
std::chrono::microseconds  now,
ClearExpiredFun  clearExpired,
EmplaceExpiredFun  emplaceExpired 
)
pure virtual

Implemented in InvRequestTrackerImpl.

◆ PostGetRequestableSanityCheck()

virtual void InvRequestTrackerImplInterface::PostGetRequestableSanityCheck ( std::chrono::microseconds  now) const
pure virtual

Implemented in InvRequestTrackerImpl.

◆ ReceivedInv()

virtual void InvRequestTrackerImplInterface::ReceivedInv ( NodeId  peer,
const uint256 invid,
bool  preferred,
std::chrono::microseconds  reqtime 
)
pure virtual

Implemented in InvRequestTrackerImpl.

◆ ReceivedResponse()

virtual void InvRequestTrackerImplInterface::ReceivedResponse ( NodeId  peer,
const uint256 invid 
)
pure virtual

Implemented in InvRequestTrackerImpl.

◆ RequestedData()

virtual void InvRequestTrackerImplInterface::RequestedData ( NodeId  peer,
const uint256 invid,
std::chrono::microseconds  expiry 
)
pure virtual

Implemented in InvRequestTrackerImpl.

◆ SanityCheck()

virtual void InvRequestTrackerImplInterface::SanityCheck ( ) const
pure virtual

Implemented in InvRequestTrackerImpl.

◆ Size()

virtual size_t InvRequestTrackerImplInterface::Size ( ) const
pure virtual

Implemented in InvRequestTrackerImpl.

Friends And Related Function Documentation

◆ InvRequestTracker

template<class InvId >
friend class InvRequestTracker
friend

Definition at line 122 of file invrequest.h.


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