5 #ifndef BITCOIN_NODE_TXDOWNLOADMAN_H 6 #define BITCOIN_NODE_TXDOWNLOADMAN_H 21 class TxDownloadManagerImpl;
76 this->m_txns = std::move(other.m_txns);
77 this->m_senders = std::move(other.m_senders);
83 return strprintf(
"parent %s (wtxid=%s, sender=%d) + child %s (wtxid=%s, sender=%d)",
84 m_txns.front()->GetHash().ToString(),
85 m_txns.front()->GetWitnessHash().ToString(),
87 m_txns.back()->GetHash().ToString(),
88 m_txns.back()->GetWitnessHash().ToString(),
120 const std::unique_ptr<TxDownloadManagerImpl>
m_impl;
178 #endif // BITCOIN_NODE_TXDOWNLOADMAN_H std::shared_ptr< const CTransaction > CTransactionRef
static constexpr auto OVERLOADED_PEER_TX_DELAY
How long to delay requesting transactions from overloaded peers (see MAX_PEER_TX_REQUEST_IN_FLIGHT).
static constexpr int32_t MAX_PEER_TX_REQUEST_IN_FLIGHT
Maximum number of in-flight transaction requests from a peer.
std::vector< Txid > m_unique_parents
bool AddTxAnnouncement(NodeId peer, const GenTxid >xid, std::chrono::microseconds now)
Consider adding this tx hash to txrequest.
static constexpr auto TXID_RELAY_DELAY
How long to delay requesting transactions via txids, if we have wtxid-relaying peers.
void ConnectedPeer(NodeId nodeid, const TxDownloadConnectionInfo &info)
Creates a new PeerInfo.
std::optional< PackageToValidate > m_package_to_validate
Data structure to keep track of, and schedule, transaction downloads from peers.
CTransactionRef GetTxToReconsider(NodeId nodeid)
Returns next orphan tx to consider, or nullptr if none exist.
const bool m_relay_permissions
Whether this peer has Relay permissions.
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
void MempoolAcceptedTx(const CTransactionRef &tx)
Respond to successful transaction submission to mempool.
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set. ...
const CTxMemPool & m_mempool
Read-only reference to mempool.
bool HaveMoreWork(NodeId nodeid) const
Whether there are any orphans to reconsider for this peer.
void ReceivedNotFound(NodeId nodeid, const std::vector< uint256 > &txhashes)
Should be called when a notfound for a tx has been received.
std::pair< bool, std::optional< PackageToValidate > > ReceivedTx(NodeId nodeid, const CTransactionRef &ptx)
Marks a tx as ReceivedResponse in txrequest and checks whether AlreadyHaveTx.
RejectedTxTodo MempoolRejectedTx(const CTransactionRef &ptx, const TxValidationState &state, NodeId nodeid, bool first_time_failure)
Respond to transaction rejected from mempool.
FastRandomContext & m_rng
RNG provided by caller.
const bool m_wtxid_relay
Whether this peer supports wtxid relay.
const std::unique_ptr< TxDownloadManagerImpl > m_impl
static constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS
Maximum number of transactions to consider for requesting, per peer.
Class responsible for deciding what transactions to request and, once downloaded, whether and how to ...
const bool m_preferred
Whether this peer is preferred for transaction download.
std::vector< TxOrphanage::OrphanTxBase > GetOrphanTransactions() const
Wrapper for TxOrphanage::GetOrphanTransactions.
static constexpr auto GETDATA_TX_INTERVAL
How long to wait before downloading a transaction from an additional peer.
TxDownloadManager(const TxDownloadOptions &options)
bool m_deterministic_txrequest
Instantiate TxRequestTracker as deterministic (used for tests).
bool m_should_add_extra_compact_tx
const uint32_t m_max_orphan_txs
Maximum number of transactions allowed in orphanage.
#define Assume(val)
Assume is the identity function.
std::vector< GenTxid > GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time)
Get getdata requests to send.
void DisconnectedPeer(NodeId nodeid)
Deletes all txrequest announcements and orphans for a given peer.
static constexpr auto NONPREF_PEER_TX_DELAY
How long to delay requesting transactions from non-preferred peers.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
PackageToValidate(PackageToValidate &&other)
std::vector< NodeId > m_senders
PackageToValidate & operator=(PackageToValidate &&other)
void CheckIsEmpty() const
Check that all data structures are empty.
void BlockConnected(const std::shared_ptr< const CBlock > &pblock)
void MempoolRejectedPackage(const Package &package)
Respond to package rejected from mempool.
std::string ToString() const
A generic txid reference (txid or wtxid).
PackageToValidate(const CTransactionRef &parent, const CTransactionRef &child, NodeId parent_sender, NodeId child_sender)
Construct a 1-parent-1-child package.