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