Bitcoin ABC 0.34.5
P2P Digital Currency
Loading...
Searching...
No Matches
txdownloadman_impl.h
Go to the documentation of this file.
1// Copyright (c) 2024 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
6#define BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
7
9
10#include <common/bloom.h>
11#include <invrequest.h>
12#include <primitives/block.h>
13#include <primitives/txid.h>
14#include <random.h>
15
16#include <map>
17
18class CTxMemPool;
19namespace node {
21public:
24
27
48
50
78
82
89
93
95 : m_opts{options}, m_rng{options.m_deterministic_txrequest},
96 m_txrequest{options.m_deterministic_txrequest} {}
97
105
111 std::map<NodeId, PeerInfo> m_peer_info;
112
113 void ActiveTipChange();
114 void BlockConnected(const std::shared_ptr<const CBlock> &pblock);
115 void BlockDisconnected();
116
127 bool AlreadyHaveTx(const TxId &txid, bool include_reconsiderable);
128
129 void ConnectedPeer(NodeId nodeid, const TxDownloadConnectionInfo &info);
130 void DisconnectedPeer(NodeId nodeid);
131
137 bool AddTxAnnouncement(NodeId peer, const TxId &txid,
138 std::chrono::microseconds now);
139
141 std::vector<TxId> GetRequestsToSend(NodeId nodeid,
142 std::chrono::microseconds current_time);
143
145 void ReceivedNotFound(NodeId nodeid, const std::vector<TxId> &txids);
146
153 std::optional<PackageToValidate> Find1P1CPackage(const CTransactionRef &ptx,
154 NodeId nodeid);
155
156 void MempoolAcceptedTx(const CTransactionRef &tx);
158 const TxValidationState &state,
159 NodeId nodeid, bool first_time_failure);
160 void MempoolRejectedPackage(const Package &package);
161
162 std::pair<bool, std::optional<PackageToValidate>>
163 ReceivedTx(NodeId nodeid, const CTransactionRef &ptx);
164
165 bool HaveMoreWork(NodeId nodeid);
167
168 void CheckIsEmpty();
169 void CheckIsEmpty(NodeId nodeid);
170
171 std::vector<TxOrphanage::PoolTx> GetOrphanTransactions() const;
172
173protected:
175 std::vector<TxId> GetUniqueParents(const CTransaction &tx);
176
184 bool
185 MaybeAddOrphanResolutionCandidate(const std::vector<TxId> &unique_parents,
186 const TxId &txid, NodeId nodeid,
187 std::chrono::microseconds now);
188};
189} // namespace node
190#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set.
Definition bloom.h:115
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition txmempool.h:222
Fast randomness source.
Definition random.h:411
CRollingBloomFilter m_recent_confirmed_transactions
Filter for transactions that have been recently confirmed.
CRollingBloomFilter m_recent_rejects
Filter for transactions that were recently rejected by the mempool.
InvRequestTracker< TxId > m_txrequest
Tracks candidates for requesting and downloading transaction data.
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,...
CRollingBloomFilter & RecentConfirmedTransactionsFilter()
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 anno...
RejectedTxTodo MempoolRejectedTx(const CTransactionRef &ptx, const TxValidationState &state, NodeId nodeid, bool first_time_failure)
std::pair< bool, std::optional< PackageToValidate > > ReceivedTx(NodeId nodeid, const CTransactionRef &ptx)
void MempoolAcceptedTx(const CTransactionRef &tx)
void ReceivedNotFound(NodeId nodeid, const std::vector< TxId > &txids)
Marks a tx as ReceivedResponse in txrequest.
void ConnectedPeer(NodeId nodeid, const TxDownloadConnectionInfo &info)
std::map< NodeId, PeerInfo > m_peer_info
Information for all of the peers we may download transactions from.
std::vector< TxId > GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time)
Get getdata requests to send.
CRollingBloomFilter m_recent_rejects_package_reconsiderable
Filter for: (1) txids of transactions that were recently rejected by the mempool but are eligible for...
bool AlreadyHaveTx(const TxId &txid, bool include_reconsiderable)
Check whether we already have this txid in:
TxDownloadManagerImpl(const TxDownloadOptions &options)
std::vector< TxOrphanage::PoolTx > GetOrphanTransactions() const
void BlockConnected(const std::shared_ptr< const CBlock > &pblock)
CTransactionRef GetTxToReconsider(NodeId nodeid)
std::vector< TxId > GetUniqueParents(const CTransaction &tx)
Helper for getting deduplicated vector of Txids in vin.
CRollingBloomFilter & RecentRejectsPackageReconsiderableFilter()
bool AddTxAnnouncement(NodeId peer, const TxId &txid, std::chrono::microseconds now)
Consider adding this tx hash to txrequest.
CRollingBloomFilter & RecentRejectsFilter()
void MempoolRejectedPackage(const Package &package)
int64_t NodeId
Definition eviction.h:16
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition packages.h:40
std::shared_ptr< const CTransaction > CTransactionRef
A TxId is the identifier of a transaction.
Definition txid.h:14
PeerInfo(const TxDownloadConnectionInfo &info)
const TxDownloadConnectionInfo m_connection_info
Information relevant to scheduling tx requests.