![]() |
Bitcoin ABC 0.34.5
P2P Digital Currency
|
#include <txdownloadman_impl.h>
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. | |
Definition at line 20 of file txdownloadman_impl.h.
|
inline |
Definition at line 94 of file txdownloadman_impl.h.
| void node::TxDownloadManagerImpl::ActiveTipChange | ( | ) |
| 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.
| bool node::TxDownloadManagerImpl::AlreadyHaveTx | ( | const TxId & | txid, |
| bool | include_reconsiderable | ||
| ) |
Check whether we already have this txid in:
Definition at line 128 of file txdownloadman_impl.cpp.
| void node::TxDownloadManagerImpl::BlockConnected | ( | const std::shared_ptr< const CBlock > & | pblock | ) |
| void node::TxDownloadManagerImpl::BlockDisconnected | ( | ) |
| void node::TxDownloadManagerImpl::CheckIsEmpty | ( | ) |
| void node::TxDownloadManagerImpl::CheckIsEmpty | ( | NodeId | nodeid | ) |
| void node::TxDownloadManagerImpl::ConnectedPeer | ( | NodeId | nodeid, |
| const TxDownloadConnectionInfo & | info | ||
| ) |
Definition at line 156 of file txdownloadman_impl.cpp.
| void node::TxDownloadManagerImpl::DisconnectedPeer | ( | NodeId | nodeid | ) |
| 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.
| std::vector< TxOrphanage::PoolTx > node::TxDownloadManagerImpl::GetOrphanTransactions | ( | ) | const |
| 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.
| CTransactionRef node::TxDownloadManagerImpl::GetTxToReconsider | ( | NodeId | nodeid | ) |
|
protected |
Helper for getting deduplicated vector of Txids in vin.
Definition at line 371 of file txdownloadman_impl.cpp.
| bool node::TxDownloadManagerImpl::HaveMoreWork | ( | NodeId | nodeid | ) |
|
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.
Definition at line 241 of file txdownloadman_impl.cpp.
| void node::TxDownloadManagerImpl::MempoolAcceptedTx | ( | const CTransactionRef & | tx | ) |
| void node::TxDownloadManagerImpl::MempoolRejectedPackage | ( | const Package & | package | ) |
| RejectedTxTodo node::TxDownloadManagerImpl::MempoolRejectedTx | ( | const CTransactionRef & | ptx, |
| const TxValidationState & | state, | ||
| NodeId | nodeid, | ||
| bool | first_time_failure | ||
| ) |
| 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.
| std::pair< bool, std::optional< PackageToValidate > > node::TxDownloadManagerImpl::ReceivedTx | ( | NodeId | nodeid, |
| const CTransactionRef & | ptx | ||
| ) |
|
inline |
|
inline |
|
inline |
| TxDownloadOptions node::TxDownloadManagerImpl::m_opts |
Definition at line 22 of file txdownloadman_impl.h.
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.
| 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.
| 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.
| CRollingBloomFilter node::TxDownloadManagerImpl::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.
(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.
| FastRandomContext node::TxDownloadManagerImpl::m_rng |
Definition at line 23 of file txdownloadman_impl.h.
| InvRequestTracker<TxId> node::TxDownloadManagerImpl::m_txrequest |
Tracks candidates for requesting and downloading transaction data.
Definition at line 26 of file txdownloadman_impl.h.