Bitcoin ABC 0.30.7
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | List of all members
InvRequestTrackerImpl Class Reference

Actual implementation for InvRequestTracker's data structure. More...

Inheritance diagram for InvRequestTrackerImpl:
[legend]
Collaboration diagram for InvRequestTrackerImpl:
[legend]

Public Member Functions

void SanityCheck () const
 
void PostGetRequestableSanityCheck (std::chrono::microseconds now) const
 
 InvRequestTrackerImpl (bool deterministic)
 
 InvRequestTrackerImpl (const InvRequestTrackerImpl &)=delete
 
InvRequestTrackerImploperator= (const InvRequestTrackerImpl &)=delete
 
 ~InvRequestTrackerImpl ()=default
 
void DisconnectedPeer (NodeId peer)
 
void ForgetInvId (const uint256 &invid)
 
void ReceivedInv (NodeId peer, const uint256 &invid, bool preferred, std::chrono::microseconds reqtime)
 
std::vector< uint256GetRequestable (NodeId peer, std::chrono::microseconds now, ClearExpiredFun clearExpired, EmplaceExpiredFun emplaceExpired)
 Find the InvIds to request now from peer. More...
 
void RequestedData (NodeId peer, const uint256 &invid, std::chrono::microseconds expiry)
 
void ReceivedResponse (NodeId peer, const uint256 &invid)
 
size_t CountInFlight (NodeId peer) const
 
size_t CountCandidates (NodeId peer) const
 
size_t Count (NodeId peer) const
 
size_t Size () const
 Count how many announcements are being tracked in total across all peers and transactions. More...
 
uint64_t ComputePriority (const uint256 &invid, NodeId peer, bool preferred) const
 
- Public Member Functions inherited from InvRequestTrackerImplInterface
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
 

Private Member Functions

template<typename Tag >
Iter< Tag > Erase (Iter< Tag > it)
 Wrapper around Index::...::erase that keeps m_peerinfo up to date. More...
 
template<typename Tag , typename Modifier >
void Modify (Iter< Tag > it, Modifier modifier)
 Wrapper around Index::...::modify that keeps m_peerinfo up to date. More...
 
void PromoteCandidateReady (Iter< ByInvId > it)
 Convert a CANDIDATE_DELAYED announcement into a CANDIDATE_READY. More...
 
void ChangeAndReselect (Iter< ByInvId > it, State new_state)
 Change the state of an announcement to something non-IsSelected(). More...
 
bool IsOnlyNonCompleted (Iter< ByInvId > it)
 Check if 'it' is the only announcement for a given invid that isn't COMPLETED. More...
 
bool MakeCompleted (Iter< ByInvId > it)
 Convert any announcement to a COMPLETED one. More...
 
void SetTimePoint (std::chrono::microseconds now, ClearExpiredFun clearExpired, EmplaceExpiredFun emplaceExpired)
 Make the data structure consistent with a given point in time: More...
 

Private Attributes

SequenceNumber m_current_sequence {0}
 The current sequence number. More...
 
const PriorityComputer m_computer
 This tracker's priority computer. More...
 
Index m_index
 This tracker's main data structure. More...
 
std::unordered_map< NodeId, PeerInfo > m_peerinfo
 Map with this tracker's per-peer statistics. More...
 

Additional Inherited Members

- Public Types inherited from InvRequestTrackerImplInterface
using ClearExpiredFun = const std::function< void()> &
 
using EmplaceExpiredFun = const std::function< void(const NodeId &, const uint256 &)> &
 

Detailed Description

Actual implementation for InvRequestTracker's data structure.

Definition at line 356 of file invrequest.cpp.

Constructor & Destructor Documentation

◆ InvRequestTrackerImpl() [1/2]

InvRequestTrackerImpl::InvRequestTrackerImpl ( bool  deterministic)
inlineexplicit

Definition at line 623 of file invrequest.cpp.

◆ InvRequestTrackerImpl() [2/2]

InvRequestTrackerImpl::InvRequestTrackerImpl ( const InvRequestTrackerImpl )
delete

◆ ~InvRequestTrackerImpl()

InvRequestTrackerImpl::~InvRequestTrackerImpl ( )
default

Member Function Documentation

◆ ChangeAndReselect()

void InvRequestTrackerImpl::ChangeAndReselect ( Iter< ByInvId >  it,
State  new_state 
)
inlineprivate

Change the state of an announcement to something non-IsSelected().

If it was IsSelected(), the next best announcement will be marked CANDIDATE_BEST.

Definition at line 499 of file invrequest.cpp.

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

◆ ComputePriority()

uint64_t InvRequestTrackerImpl::ComputePriority ( const uint256 invid,
NodeId  peer,
bool  preferred 
) const
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 855 of file invrequest.cpp.

◆ Count()

size_t InvRequestTrackerImpl::Count ( NodeId  peer) const
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 843 of file invrequest.cpp.

◆ CountCandidates()

size_t InvRequestTrackerImpl::CountCandidates ( NodeId  peer) const
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 834 of file invrequest.cpp.

◆ CountInFlight()

size_t InvRequestTrackerImpl::CountInFlight ( NodeId  peer) const
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 826 of file invrequest.cpp.

◆ DisconnectedPeer()

void InvRequestTrackerImpl::DisconnectedPeer ( NodeId  peer)
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 641 of file invrequest.cpp.

Here is the call graph for this function:

◆ Erase()

template<typename Tag >
Iter< Tag > InvRequestTrackerImpl::Erase ( Iter< Tag >  it)
inlineprivate

Wrapper around Index::...::erase that keeps m_peerinfo up to date.

Definition at line 433 of file invrequest.cpp.

◆ ForgetInvId()

void InvRequestTrackerImpl::ForgetInvId ( const uint256 invid)
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 683 of file invrequest.cpp.

◆ GetRequestable()

std::vector< uint256 > InvRequestTrackerImpl::GetRequestable ( NodeId  peer,
std::chrono::microseconds  now,
ClearExpiredFun  clearExpired,
EmplaceExpiredFun  emplaceExpired 
)
inlinevirtual

Find the InvIds to request now from peer.

Implements InvRequestTrackerImplInterface.

Definition at line 718 of file invrequest.cpp.

Here is the call graph for this function:

◆ IsOnlyNonCompleted()

bool InvRequestTrackerImpl::IsOnlyNonCompleted ( Iter< ByInvId >  it)
inlineprivate

Check if 'it' is the only announcement for a given invid that isn't COMPLETED.

Definition at line 522 of file invrequest.cpp.

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

◆ MakeCompleted()

bool InvRequestTrackerImpl::MakeCompleted ( Iter< ByInvId >  it)
inlineprivate

Convert any announcement to a COMPLETED one.

If there are no non-COMPLETED announcements left for this invid, they are deleted. If this was a REQUESTED announcement, and there are other CANDIDATEs left, the best one is made CANDIDATE_BEST. Returns whether the announcement still exists.

Definition at line 553 of file invrequest.cpp.

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

◆ Modify()

template<typename Tag , typename Modifier >
void InvRequestTrackerImpl::Modify ( Iter< Tag >  it,
Modifier  modifier 
)
inlineprivate

Wrapper around Index::...::modify that keeps m_peerinfo up to date.

Definition at line 445 of file invrequest.cpp.

◆ operator=()

InvRequestTrackerImpl & InvRequestTrackerImpl::operator= ( const InvRequestTrackerImpl )
delete

◆ PostGetRequestableSanityCheck()

void InvRequestTrackerImpl::PostGetRequestableSanityCheck ( std::chrono::microseconds  now) const
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 414 of file invrequest.cpp.

Here is the call graph for this function:

◆ PromoteCandidateReady()

void InvRequestTrackerImpl::PromoteCandidateReady ( Iter< ByInvId >  it)
inlineprivate

Convert a CANDIDATE_DELAYED announcement into a CANDIDATE_READY.

If this makes it the new best CANDIDATE_READY (and no REQUESTED exists) and better than the CANDIDATE_BEST (if any), it becomes the new CANDIDATE_BEST.

Definition at line 458 of file invrequest.cpp.

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

◆ ReceivedInv()

void InvRequestTrackerImpl::ReceivedInv ( NodeId  peer,
const uint256 invid,
bool  preferred,
std::chrono::microseconds  reqtime 
)
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 691 of file invrequest.cpp.

◆ ReceivedResponse()

void InvRequestTrackerImpl::ReceivedResponse ( NodeId  peer,
const uint256 invid 
)
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 814 of file invrequest.cpp.

Here is the call graph for this function:

◆ RequestedData()

void InvRequestTrackerImpl::RequestedData ( NodeId  peer,
const uint256 invid,
std::chrono::microseconds  expiry 
)
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 751 of file invrequest.cpp.

◆ SanityCheck()

void InvRequestTrackerImpl::SanityCheck ( ) const
inlinevirtual

Implements InvRequestTrackerImplInterface.

Definition at line 372 of file invrequest.cpp.

Here is the call graph for this function:

◆ SetTimePoint()

void InvRequestTrackerImpl::SetTimePoint ( std::chrono::microseconds  now,
ClearExpiredFun  clearExpired,
EmplaceExpiredFun  emplaceExpired 
)
inlineprivate

Make the data structure consistent with a given point in time:

  • REQUESTED annoucements with expiry <= now are turned into COMPLETED.
  • CANDIDATE_DELAYED announcements with reqtime <= now are turned into CANDIDATE_{READY,BEST}.
  • CANDIDATE_{READY,BEST} announcements with reqtime > now are turned into CANDIDATE_DELAYED.

Definition at line 585 of file invrequest.cpp.

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

◆ Size()

size_t InvRequestTrackerImpl::Size ( ) const
inlinevirtual

Count how many announcements are being tracked in total across all peers and transactions.

Implements InvRequestTrackerImplInterface.

Definition at line 853 of file invrequest.cpp.

Member Data Documentation

◆ m_computer

const PriorityComputer InvRequestTrackerImpl::m_computer
private

This tracker's priority computer.

Definition at line 362 of file invrequest.cpp.

◆ m_current_sequence

SequenceNumber InvRequestTrackerImpl::m_current_sequence {0}
private

The current sequence number.

Increases for every announcement. This is used to sort invid returned by GetRequestable in announcement order.

Definition at line 359 of file invrequest.cpp.

◆ m_index

Index InvRequestTrackerImpl::m_index
private

This tracker's main data structure.

See SanityCheck() for the invariants that apply to it.

Definition at line 366 of file invrequest.cpp.

◆ m_peerinfo

std::unordered_map<NodeId, PeerInfo> InvRequestTrackerImpl::m_peerinfo
private

Map with this tracker's per-peer statistics.

Definition at line 369 of file invrequest.cpp.


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