Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
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 GetCandidatePeers (const uint256 &txhash, std::vector< NodeId > &result_peers) const
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.
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.
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.
template<typename Tag, typename Modifier>
void Modify (Iter< Tag > it, Modifier modifier)
 Wrapper around Index::...::modify that keeps m_peerinfo up to date.
void PromoteCandidateReady (Iter< ByTxHash > it)
void ChangeAndReselect (Iter< ByTxHash > it, State new_state)
bool IsOnlyNonCompleted (Iter< ByTxHash > it)
 Check if 'it' is the only announcement for a given txhash that isn't COMPLETED.
bool MakeCompleted (Iter< ByTxHash > it)
 Convert any announcement to a COMPLETED one.
void SetTimePoint (std::chrono::microseconds now, std::vector< std::pair< NodeId, GenTxid > > *expired)

Private Attributes

SequenceNumber m_current_sequence {0}
const PriorityComputer m_computer
 This tracker's priority computer.
Index m_index
 This tracker's main data structure. See SanityCheck() for the invariants that apply to it.
std::unordered_map< NodeId, PeerInfo > m_peerinfo
 Map with this tracker's per-peer statistics.

Detailed Description

Actual implementation for TxRequestTracker's data structure.

Definition at line 301 of file txrequest.cpp.

Constructor & Destructor Documentation

◆ Impl() [1/2]

TxRequestTracker::Impl::Impl ( bool deterministic)
inlineexplicit

Definition at line 516 of file txrequest.cpp.

Here is the caller graph for this function:

◆ Impl() [2/2]

TxRequestTracker::Impl::Impl ( const Impl & )
delete
Here is the call graph for this function:

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 421 of file txrequest.cpp.

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

◆ 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 529 of file txrequest.cpp.

Here is the call graph for this function:

◆ 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 368 of file txrequest.cpp.

Here is the caller graph for this function:

◆ ForgetTxHash()

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

Definition at line 560 of file txrequest.cpp.

Here is the call graph for this function:

◆ GetCandidatePeers()

void TxRequestTracker::Impl::GetCandidatePeers ( const uint256 & txhash,
std::vector< NodeId > & result_peers ) const
inline

Definition at line 568 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 438 of file txrequest.cpp.

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

◆ 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 457 of file txrequest.cpp.

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

◆ 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 379 of file txrequest.cpp.

Here is the caller graph for this function:

◆ operator=()

Impl & TxRequestTracker::Impl::operator= ( const Impl & )
delete
Here is the call graph for this function:

◆ PostGetRequestableSanityCheck()

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

Definition at line 350 of file txrequest.cpp.

Here is the call graph for this function:

◆ 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 392 of file txrequest.cpp.

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

◆ 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.

Here is the call graph for this function:

◆ RequestedTx()

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

Definition at line 626 of file txrequest.cpp.

Here is the call graph for this function:

◆ SanityCheck()

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

Definition at line 316 of file txrequest.cpp.

Here is the call graph for this function:

◆ 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 announcements 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 484 of file txrequest.cpp.

Here is the call graph for this function:
Here is the caller 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 307 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 304 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 310 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 313 of file txrequest.cpp.


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