Bitcoin Core  0.20.99
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TxRequestTracker::Impl Class Reference

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

Collaboration diagram for TxRequestTracker::Impl:
[legend]

Public Member Functions

void SanityCheck () const
 
void PostGetRequestableSanityCheck (std::chrono::microseconds now) const
 
 Impl (bool deterministic)
 
 Impl (const Impl &)=delete
 
Imploperator= (const Impl &)=delete
 
void DisconnectedPeer (NodeId peer)
 
void ForgetTxHash (const uint256 &txhash)
 
void ReceivedInv (NodeId peer, const GenTxid &gtxid, bool preferred, std::chrono::microseconds reqtime)
 
std::vector< GenTxidGetRequestable (NodeId peer, std::chrono::microseconds now, std::vector< std::pair< NodeId, GenTxid >> *expired)
 Find the GenTxids to request now from peer. More...
 
void RequestedTx (NodeId peer, const uint256 &txhash, std::chrono::microseconds expiry)
 
void ReceivedResponse (NodeId peer, const uint256 &txhash)
 
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 &txhash, NodeId peer, bool preferred) const
 

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< ByTxHash > it)
 Convert a CANDIDATE_DELAYED announcement into a CANDIDATE_READY. More...
 
void ChangeAndReselect (Iter< ByTxHash > it, State new_state)
 Change the state of an announcement to something non-IsSelected(). More...
 
bool IsOnlyNonCompleted (Iter< ByTxHash > it)
 Check if 'it' is the only announcement for a given txhash that isn't COMPLETED. More...
 
bool MakeCompleted (Iter< ByTxHash > it)
 Convert any announcement to a COMPLETED one. More...
 
void SetTimePoint (std::chrono::microseconds now, std::vector< std::pair< NodeId, GenTxid >> *expired)
 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. See SanityCheck() for the invariants that apply to it. More...
 
std::unordered_map< NodeId, PeerInfo > m_peerinfo
 Map with this tracker's per-peer statistics. More...
 

Detailed Description

Actual implementation for TxRequestTracker's data structure.

Definition at line 310 of file txrequest.cpp.

Constructor & Destructor Documentation

◆ Impl() [1/2]

TxRequestTracker::Impl::Impl ( bool  deterministic)
inline

Definition at line 525 of file txrequest.cpp.

◆ Impl() [2/2]

TxRequestTracker::Impl::Impl ( const Impl )
delete

Member Function Documentation

◆ ChangeAndReselect()

void TxRequestTracker::Impl::ChangeAndReselect ( Iter< ByTxHash >  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 430 of file txrequest.cpp.

◆ ComputePriority()

uint64_t TxRequestTracker::Impl::ComputePriority ( const uint256 txhash,
NodeId  peer,
bool  preferred 
) const
inline

Definition at line 705 of file txrequest.cpp.

◆ Count()

size_t TxRequestTracker::Impl::Count ( NodeId  peer) const
inline

Definition at line 695 of file txrequest.cpp.

◆ CountCandidates()

size_t TxRequestTracker::Impl::CountCandidates ( NodeId  peer) const
inline

Definition at line 688 of file txrequest.cpp.

◆ CountInFlight()

size_t TxRequestTracker::Impl::CountInFlight ( NodeId  peer) const
inline

Definition at line 681 of file txrequest.cpp.

◆ DisconnectedPeer()

void TxRequestTracker::Impl::DisconnectedPeer ( NodeId  peer)
inline

Definition at line 538 of file txrequest.cpp.

◆ Erase()

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

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

Definition at line 377 of file txrequest.cpp.

Here is the call graph for this function:

◆ ForgetTxHash()

void TxRequestTracker::Impl::ForgetTxHash ( const uint256 txhash)
inline

Definition at line 569 of file txrequest.cpp.

◆ GetRequestable()

std::vector<GenTxid> TxRequestTracker::Impl::GetRequestable ( NodeId  peer,
std::chrono::microseconds  now,
std::vector< std::pair< NodeId, GenTxid >> *  expired 
)
inline

Find the GenTxids to request now from peer.

Definition at line 597 of file txrequest.cpp.

Here is the call graph for this function:

◆ IsOnlyNonCompleted()

bool TxRequestTracker::Impl::IsOnlyNonCompleted ( Iter< ByTxHash >  it)
inlineprivate

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

Definition at line 447 of file txrequest.cpp.

◆ MakeCompleted()

bool TxRequestTracker::Impl::MakeCompleted ( Iter< ByTxHash >  it)
inlineprivate

Convert any announcement to a COMPLETED one.

If there are no non-COMPLETED announcements left for this txhash, 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 466 of file txrequest.cpp.

◆ Modify()

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

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

Definition at line 388 of file txrequest.cpp.

◆ operator=()

Impl& TxRequestTracker::Impl::operator= ( const Impl )
delete

◆ PostGetRequestableSanityCheck()

void TxRequestTracker::Impl::PostGetRequestableSanityCheck ( std::chrono::microseconds  now) const
inline

Definition at line 359 of file txrequest.cpp.

◆ PromoteCandidateReady()

void TxRequestTracker::Impl::PromoteCandidateReady ( Iter< ByTxHash >  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 401 of file txrequest.cpp.

◆ ReceivedInv()

void TxRequestTracker::Impl::ReceivedInv ( NodeId  peer,
const GenTxid gtxid,
bool  preferred,
std::chrono::microseconds  reqtime 
)
inline

Definition at line 577 of file txrequest.cpp.

◆ ReceivedResponse()

void TxRequestTracker::Impl::ReceivedResponse ( NodeId  peer,
const uint256 txhash 
)
inline

Definition at line 671 of file txrequest.cpp.

◆ RequestedTx()

void TxRequestTracker::Impl::RequestedTx ( NodeId  peer,
const uint256 txhash,
std::chrono::microseconds  expiry 
)
inline

Definition at line 626 of file txrequest.cpp.

◆ SanityCheck()

void TxRequestTracker::Impl::SanityCheck ( ) const
inline

Definition at line 325 of file txrequest.cpp.

◆ SetTimePoint()

void TxRequestTracker::Impl::SetTimePoint ( std::chrono::microseconds  now,
std::vector< std::pair< NodeId, GenTxid >> *  expired 
)
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 493 of file txrequest.cpp.

Here is the call graph for this function:

◆ Size()

size_t TxRequestTracker::Impl::Size ( ) const
inline

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

Definition at line 703 of file txrequest.cpp.

Member Data Documentation

◆ m_computer

const PriorityComputer TxRequestTracker::Impl::m_computer
private

This tracker's priority computer.

Definition at line 316 of file txrequest.cpp.

◆ m_current_sequence

SequenceNumber TxRequestTracker::Impl::m_current_sequence {0}
private

The current sequence number.

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

Definition at line 313 of file txrequest.cpp.

◆ m_index

Index TxRequestTracker::Impl::m_index
private

This tracker's main data structure. See SanityCheck() for the invariants that apply to it.

Definition at line 319 of file txrequest.cpp.

◆ m_peerinfo

std::unordered_map<NodeId, PeerInfo> TxRequestTracker::Impl::m_peerinfo
private

Map with this tracker's per-peer statistics.

Definition at line 322 of file txrequest.cpp.


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