Bitcoin Core 28.99.0
P2P Digital Currency
|
Class responsible for deciding what transactions to request and, once downloaded, whether and how to validate them. More...
#include <txdownloadman.h>
Public Member Functions | |
TxDownloadManager (const TxDownloadOptions &options) | |
~TxDownloadManager () | |
void | ActiveTipChange () |
void | BlockConnected (const std::shared_ptr< const CBlock > &pblock) |
void | BlockDisconnected () |
void | ConnectedPeer (NodeId nodeid, const TxDownloadConnectionInfo &info) |
Creates a new PeerInfo. More... | |
void | DisconnectedPeer (NodeId nodeid) |
Deletes all txrequest announcements and orphans for a given peer. More... | |
bool | AddTxAnnouncement (NodeId peer, const GenTxid >xid, std::chrono::microseconds now, bool p2p_inv) |
Consider adding this tx hash to txrequest. More... | |
std::vector< GenTxid > | GetRequestsToSend (NodeId nodeid, std::chrono::microseconds current_time) |
Get getdata requests to send. More... | |
void | ReceivedNotFound (NodeId nodeid, const std::vector< uint256 > &txhashes) |
Should be called when a notfound for a tx has been received. More... | |
void | MempoolAcceptedTx (const CTransactionRef &tx) |
Respond to successful transaction submission to mempool. More... | |
RejectedTxTodo | MempoolRejectedTx (const CTransactionRef &ptx, const TxValidationState &state, NodeId nodeid, bool first_time_failure) |
Respond to transaction rejected from mempool. More... | |
void | MempoolRejectedPackage (const Package &package) |
Respond to package rejected from mempool. More... | |
std::pair< bool, std::optional< PackageToValidate > > | ReceivedTx (NodeId nodeid, const CTransactionRef &ptx) |
Marks a tx as ReceivedResponse in txrequest and checks whether AlreadyHaveTx. More... | |
bool | HaveMoreWork (NodeId nodeid) const |
Whether there are any orphans to reconsider for this peer. More... | |
CTransactionRef | GetTxToReconsider (NodeId nodeid) |
Returns next orphan tx to consider, or nullptr if none exist. More... | |
void | CheckIsEmpty () const |
Check that all data structures are empty. More... | |
void | CheckIsEmpty (NodeId nodeid) const |
Check that all data structures that track per-peer information have nothing for this peer. More... | |
std::vector< TxOrphanage::OrphanTxBase > | GetOrphanTransactions () const |
Wrapper for TxOrphanage::GetOrphanTransactions. More... | |
Private Attributes | |
const std::unique_ptr< TxDownloadManagerImpl > | m_impl |
Class responsible for deciding what transactions to request and, once downloaded, whether and how to validate them.
It is also responsible for deciding what transaction packages to validate and how to resolve orphan transactions. Its data structures include TxRequestTracker for scheduling requests, rolling bloom filters for remembering transactions that have already been {accepted, rejected, confirmed}, an orphanage, and a registry of each peer's transaction relay-related information.
Caller needs to interact with TxDownloadManager:
This class is not thread-safe. Access must be synchronized using an external mutex.
Definition at line 119 of file txdownloadman.h.
|
explicit |
Definition at line 17 of file txdownloadman_impl.cpp.
|
default |
void node::TxDownloadManager::ActiveTipChange | ( | ) |
Definition at line 22 of file txdownloadman_impl.cpp.
bool node::TxDownloadManager::AddTxAnnouncement | ( | NodeId | peer, |
const GenTxid & | gtxid, | ||
std::chrono::microseconds | now, | ||
bool | p2p_inv | ||
) |
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.
[in] | p2p_inv | When true, only add this announcement if we don't already have the tx. Returns true if this was a dropped inv (p2p_inv=true and we already have the tx), false otherwise. |
Definition at line 42 of file txdownloadman_impl.cpp.
void node::TxDownloadManager::BlockConnected | ( | const std::shared_ptr< const CBlock > & | pblock | ) |
Definition at line 26 of file txdownloadman_impl.cpp.
void node::TxDownloadManager::BlockDisconnected | ( | ) |
Definition at line 30 of file txdownloadman_impl.cpp.
void node::TxDownloadManager::CheckIsEmpty | ( | ) | const |
Check that all data structures are empty.
Definition at line 78 of file txdownloadman_impl.cpp.
void node::TxDownloadManager::CheckIsEmpty | ( | NodeId | nodeid | ) | const |
Check that all data structures that track per-peer information have nothing for this peer.
Definition at line 82 of file txdownloadman_impl.cpp.
void node::TxDownloadManager::ConnectedPeer | ( | NodeId | nodeid, |
const TxDownloadConnectionInfo & | info | ||
) |
Creates a new PeerInfo.
Saves the connection info to calculate tx announcement delays later.
Definition at line 34 of file txdownloadman_impl.cpp.
void node::TxDownloadManager::DisconnectedPeer | ( | NodeId | nodeid | ) |
Deletes all txrequest announcements and orphans for a given peer.
Definition at line 38 of file txdownloadman_impl.cpp.
std::vector< TxOrphanage::OrphanTxBase > node::TxDownloadManager::GetOrphanTransactions | ( | ) | const |
Wrapper for TxOrphanage::GetOrphanTransactions.
Definition at line 86 of file txdownloadman_impl.cpp.
std::vector< GenTxid > node::TxDownloadManager::GetRequestsToSend | ( | NodeId | nodeid, |
std::chrono::microseconds | current_time | ||
) |
Get getdata requests to send.
Definition at line 46 of file txdownloadman_impl.cpp.
CTransactionRef node::TxDownloadManager::GetTxToReconsider | ( | NodeId | nodeid | ) |
Returns next orphan tx to consider, or nullptr if none exist.
Definition at line 74 of file txdownloadman_impl.cpp.
bool node::TxDownloadManager::HaveMoreWork | ( | NodeId | nodeid | ) | const |
Whether there are any orphans to reconsider for this peer.
Definition at line 70 of file txdownloadman_impl.cpp.
void node::TxDownloadManager::MempoolAcceptedTx | ( | const CTransactionRef & | tx | ) |
Respond to successful transaction submission to mempool.
Definition at line 54 of file txdownloadman_impl.cpp.
void node::TxDownloadManager::MempoolRejectedPackage | ( | const Package & | package | ) |
Respond to package rejected from mempool.
Definition at line 62 of file txdownloadman_impl.cpp.
RejectedTxTodo node::TxDownloadManager::MempoolRejectedTx | ( | const CTransactionRef & | ptx, |
const TxValidationState & | state, | ||
NodeId | nodeid, | ||
bool | first_time_failure | ||
) |
Respond to transaction rejected from mempool.
Definition at line 58 of file txdownloadman_impl.cpp.
void node::TxDownloadManager::ReceivedNotFound | ( | NodeId | nodeid, |
const std::vector< uint256 > & | txhashes | ||
) |
Should be called when a notfound for a tx has been received.
Definition at line 50 of file txdownloadman_impl.cpp.
std::pair< bool, std::optional< PackageToValidate > > node::TxDownloadManager::ReceivedTx | ( | NodeId | nodeid, |
const CTransactionRef & | ptx | ||
) |
Marks a tx as ReceivedResponse in txrequest and checks whether AlreadyHaveTx.
Return a bool indicating whether this tx should be validated. If false, optionally, a PackageToValidate.
Definition at line 66 of file txdownloadman_impl.cpp.
|
private |
Definition at line 120 of file txdownloadman.h.