Bitcoin ABC 0.34.5
P2P Digital Currency
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
node::TxDownloadManagerImpl Class Reference

#include <txdownloadman_impl.h>

Collaboration diagram for node::TxDownloadManagerImpl:
[legend]

Classes

struct  PeerInfo
 

Public Member Functions

CRollingBloomFilter & RecentRejectsFilter ()
 
CRollingBloomFilter & RecentRejectsPackageReconsiderableFilter ()
 
CRollingBloomFilter & RecentConfirmedTransactionsFilter ()
 
 TxDownloadManagerImpl (const TxDownloadOptions &options)
 
void ActiveTipChange ()
 
void BlockConnected (const std::shared_ptr< const CBlock > &pblock)
 
void BlockDisconnected ()
 
bool AlreadyHaveTx (const TxId &txid, bool include_reconsiderable)
 Check whether we already have this txid in:
 
void ConnectedPeer (NodeId nodeid, const TxDownloadConnectionInfo &info)
 
void DisconnectedPeer (NodeId nodeid)
 
bool AddTxAnnouncement (NodeId peer, const TxId &txid, std::chrono::microseconds now)
 Consider adding this tx hash to txrequest.
 
std::vector< TxId > GetRequestsToSend (NodeId nodeid, std::chrono::microseconds current_time)
 Get getdata requests to send.
 
void ReceivedNotFound (NodeId nodeid, const std::vector< TxId > &txids)
 Marks a tx as ReceivedResponse in txrequest.
 
std::optional< PackageToValidate > Find1P1CPackage (const CTransactionRef &ptx, NodeId nodeid)
 Look for a child of this transaction in the orphanage to form a 1-parent-1-child package, skipping any combinations that have already been tried.
 
void MempoolAcceptedTx (const CTransactionRef &tx)
 
RejectedTxTodo MempoolRejectedTx (const CTransactionRef &ptx, const TxValidationState &state, NodeId nodeid, bool first_time_failure)
 
void MempoolRejectedPackage (const Package &package)
 
std::pair< bool, std::optional< PackageToValidate > > ReceivedTx (NodeId nodeid, const CTransactionRef &ptx)
 
bool HaveMoreWork (NodeId nodeid)
 
CTransactionRef GetTxToReconsider (NodeId nodeid)
 
void CheckIsEmpty ()
 
void CheckIsEmpty (NodeId nodeid)
 
std::vector< TxOrphanage::PoolTx > GetOrphanTransactions () const
 

Public Attributes

TxDownloadOptions m_opts
 
FastRandomContext m_rng
 
InvRequestTracker< TxId > m_txrequest
 Tracks candidates for requesting and downloading transaction data.
 
CRollingBloomFilter m_recent_rejects {120'000, 0.000'001}
 Filter for transactions that were recently rejected by the mempool.
 
CRollingBloomFilter m_recent_rejects_package_reconsiderable
 Filter for: (1) txids of transactions that were recently rejected by the mempool but are eligible for reconsideration if submitted with other transactions.
 
CRollingBloomFilter m_recent_confirmed_transactions {24'000, 0.000'001}
 Filter for transactions that have been recently confirmed.
 
std::map< NodeId, PeerInfo > m_peer_info
 Information for all of the peers we may download transactions from.
 

Protected Member Functions

std::vector< TxId > GetUniqueParents (const CTransaction &tx)
 Helper for getting deduplicated vector of Txids in vin.
 
bool MaybeAddOrphanResolutionCandidate (const std::vector< TxId > &unique_parents, const TxId &txid, NodeId nodeid, std::chrono::microseconds now)
 If this peer is an orphan resolution candidate for this transaction, treat the unique_parents as announced by this peer; add them as new invs to m_txrequest.
 

Detailed Description

Definition at line 20 of file txdownloadman_impl.h.

Constructor & Destructor Documentation

◆ TxDownloadManagerImpl()

node::TxDownloadManagerImpl::TxDownloadManagerImpl ( const TxDownloadOptions &  options)
inline

Definition at line 94 of file txdownloadman_impl.h.

Member Function Documentation

◆ ActiveTipChange()

void node::TxDownloadManagerImpl::ActiveTipChange ( )

Definition at line 96 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ AddTxAnnouncement()

bool node::TxDownloadManagerImpl::AddTxAnnouncement ( NodeId  peer,
const TxId &  txid,
std::chrono::microseconds  now 
)

Consider adding this tx hash to txrequest.

Should be called whenever a new inv has been received. Also called internally when a transaction is missing parents so that we can request them.

Definition at line 176 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ AlreadyHaveTx()

bool node::TxDownloadManagerImpl::AlreadyHaveTx ( const TxId &  txid,
bool  include_reconsiderable 
)

Check whether we already have this txid in:

  • mempool
  • orphanage
  • conflicting pool
  • m_recent_rejects
  • m_recent_rejects_package_reconsiderable (if include_reconsiderable = true)
  • m_recent_confirmed_transactions

Definition at line 128 of file txdownloadman_impl.cpp.

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

◆ BlockConnected()

void node::TxDownloadManagerImpl::BlockConnected ( const std::shared_ptr< const CBlock > &  pblock)

Definition at line 101 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ BlockDisconnected()

void node::TxDownloadManagerImpl::BlockDisconnected ( )

Definition at line 116 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ CheckIsEmpty() [1/2]

void node::TxDownloadManagerImpl::CheckIsEmpty ( )

Definition at line 607 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ CheckIsEmpty() [2/2]

void node::TxDownloadManagerImpl::CheckIsEmpty ( NodeId  nodeid)

Definition at line 604 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ ConnectedPeer()

void node::TxDownloadManagerImpl::ConnectedPeer ( NodeId  nodeid,
const TxDownloadConnectionInfo &  info 
)

Definition at line 156 of file txdownloadman_impl.cpp.

◆ DisconnectedPeer()

void node::TxDownloadManagerImpl::DisconnectedPeer ( NodeId  nodeid)

Definition at line 166 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ Find1P1CPackage()

std::optional< PackageToValidate > node::TxDownloadManagerImpl::Find1P1CPackage ( const CTransactionRef &  ptx,
NodeId  nodeid 
)

Look for a child of this transaction in the orphanage to form a 1-parent-1-child package, skipping any combinations that have already been tried.

Return the resulting package along with the senders of its respective transactions, or std::nullopt if no package is found.

Definition at line 328 of file txdownloadman_impl.cpp.

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

◆ GetOrphanTransactions()

std::vector< TxOrphanage::PoolTx > node::TxDownloadManagerImpl::GetOrphanTransactions ( ) const

Definition at line 614 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ GetRequestsToSend()

std::vector< TxId > node::TxDownloadManagerImpl::GetRequestsToSend ( NodeId  nodeid,
std::chrono::microseconds  current_time 
)

Get getdata requests to send.

Definition at line 289 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ GetTxToReconsider()

CTransactionRef node::TxDownloadManagerImpl::GetTxToReconsider ( NodeId  nodeid)

Definition at line 598 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ GetUniqueParents()

std::vector< TxId > node::TxDownloadManagerImpl::GetUniqueParents ( const CTransaction &  tx)
protected

Helper for getting deduplicated vector of Txids in vin.

Definition at line 371 of file txdownloadman_impl.cpp.

Here is the caller graph for this function:

◆ HaveMoreWork()

bool node::TxDownloadManagerImpl::HaveMoreWork ( NodeId  nodeid)

Definition at line 592 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ MaybeAddOrphanResolutionCandidate()

bool node::TxDownloadManagerImpl::MaybeAddOrphanResolutionCandidate ( const std::vector< TxId > &  unique_parents,
const TxId &  txid,
NodeId  nodeid,
std::chrono::microseconds  now 
)
protected

If this peer is an orphan resolution candidate for this transaction, treat the unique_parents as announced by this peer; add them as new invs to m_txrequest.

Returns
whether this transaction was a valid orphan resolution candidate.

Definition at line 241 of file txdownloadman_impl.cpp.

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

◆ MempoolAcceptedTx()

void node::TxDownloadManagerImpl::MempoolAcceptedTx ( const CTransactionRef &  tx)

Definition at line 357 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ MempoolRejectedPackage()

void node::TxDownloadManagerImpl::MempoolRejectedPackage ( const Package &  package)

Definition at line 548 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ MempoolRejectedTx()

RejectedTxTodo node::TxDownloadManagerImpl::MempoolRejectedTx ( const CTransactionRef &  ptx,
const TxValidationState &  state,
NodeId  nodeid,
bool  first_time_failure 
)

Definition at line 387 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ ReceivedNotFound()

void node::TxDownloadManagerImpl::ReceivedNotFound ( NodeId  nodeid,
const std::vector< TxId > &  txids 
)

Marks a tx as ReceivedResponse in txrequest.

Definition at line 318 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ ReceivedTx()

std::pair< bool, std::optional< PackageToValidate > > node::TxDownloadManagerImpl::ReceivedTx ( NodeId  nodeid,
const CTransactionRef &  ptx 
)

Definition at line 553 of file txdownloadman_impl.cpp.

Here is the call graph for this function:

◆ RecentConfirmedTransactionsFilter()

CRollingBloomFilter & node::TxDownloadManagerImpl::RecentConfirmedTransactionsFilter ( )
inline

Definition at line 90 of file txdownloadman_impl.h.

Here is the caller graph for this function:

◆ RecentRejectsFilter()

CRollingBloomFilter & node::TxDownloadManagerImpl::RecentRejectsFilter ( )
inline

Definition at line 49 of file txdownloadman_impl.h.

Here is the caller graph for this function:

◆ RecentRejectsPackageReconsiderableFilter()

CRollingBloomFilter & node::TxDownloadManagerImpl::RecentRejectsPackageReconsiderableFilter ( )
inline

Definition at line 79 of file txdownloadman_impl.h.

Here is the caller graph for this function:

Member Data Documentation

◆ m_opts

TxDownloadOptions node::TxDownloadManagerImpl::m_opts

Definition at line 22 of file txdownloadman_impl.h.

◆ m_peer_info

std::map<NodeId, PeerInfo> node::TxDownloadManagerImpl::m_peer_info

Information for all of the peers we may download transactions from.

This is not necessarily all peers we are connected to (no block-relay-only and temporary connections).

Definition at line 111 of file txdownloadman_impl.h.

◆ m_recent_confirmed_transactions

CRollingBloomFilter node::TxDownloadManagerImpl::m_recent_confirmed_transactions {24'000, 0.000'001}

Filter for transactions that have been recently confirmed.

We use this to avoid requesting transactions that have already been confirmed.

Definition at line 88 of file txdownloadman_impl.h.

◆ m_recent_rejects

CRollingBloomFilter node::TxDownloadManagerImpl::m_recent_rejects {120'000, 0.000'001}

Filter for transactions that were recently rejected by the mempool.

These are not rerequested until the chain tip changes, at which point the entire filter is reset.

Without this filter we'd be re-requesting txs from each of our peers, increasing bandwidth consumption considerably. For instance, with 100 peers, half of which relay a tx we don't accept, that might be a 50x bandwidth increase. A flooding attacker attempting to roll-over the filter using minimum-sized, 60byte, transactions might manage to send 1000/sec if we have fast peers, so we pick 120,000 to give our peers a two minute window to send invs to us.

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.

Memory used: 1.3 MB

Definition at line 47 of file txdownloadman_impl.h.

◆ m_recent_rejects_package_reconsiderable

CRollingBloomFilter node::TxDownloadManagerImpl::m_recent_rejects_package_reconsiderable
Initial value:
{120'000,
0.000'001}

Filter for: (1) txids of transactions that were recently rejected by the mempool but are eligible for reconsideration if submitted with other transactions.

(2) packages (see GetPackageHash) we have already rejected before and should not retry.

Similar to m_recent_rejects, this filter is used to save bandwidth when e.g. all of our peers have larger mempools and thus lower minimum feerates than us.

When a transaction's error is TxValidationResult::TX_PACKAGE_RECONSIDERABLE (in a package or by itself), add its txid to this filter. When a package fails for any reason, add the combined hash to this filter.

Upon receiving an announcement for a transaction, if it exists in this filter, do not download the txdata. When considering packages, if it exists in this filter, drop it.

Reset this filter when the chain tip changes.

Parameters are picked to be the same as m_recent_rejects, with the same rationale.

Definition at line 76 of file txdownloadman_impl.h.

◆ m_rng

FastRandomContext node::TxDownloadManagerImpl::m_rng

Definition at line 23 of file txdownloadman_impl.h.

◆ m_txrequest

InvRequestTracker<TxId> node::TxDownloadManagerImpl::m_txrequest

Tracks candidates for requesting and downloading transaction data.

Definition at line 26 of file txdownloadman_impl.h.


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