@@ -854,17 +854,6 @@ class PeerManagerImpl final : public PeerManager
854
854
/* * Stalling timeout for blocks in IBD */
855
855
std::atomic<std::chrono::seconds> m_block_stalling_timeout{BLOCK_STALLING_TIMEOUT_DEFAULT};
856
856
857
- /* * Check whether we already have this gtxid in:
858
- * - mempool
859
- * - orphanage
860
- * - m_lazy_recent_rejects
861
- * - m_lazy_recent_rejects_reconsiderable (if include_reconsiderable = true)
862
- * - m_lazy_recent_confirmed_transactions
863
- * */
864
- bool AlreadyHaveTx (const GenTxid& gtxid, bool include_reconsiderable)
865
- EXCLUSIVE_LOCKS_REQUIRED(m_tx_download_mutex);
866
-
867
-
868
857
CRollingBloomFilter& RecentRejectsFilter () EXCLUSIVE_LOCKS_REQUIRED(m_tx_download_mutex)
869
858
{
870
859
AssertLockHeld (m_tx_download_mutex);
@@ -877,12 +866,6 @@ class PeerManagerImpl final : public PeerManager
877
866
return m_txdownloadman.RecentRejectsReconsiderableFilter ();
878
867
}
879
868
880
- CRollingBloomFilter& RecentConfirmedTransactionsFilter () EXCLUSIVE_LOCKS_REQUIRED(m_tx_download_mutex)
881
- {
882
- AssertLockHeld (m_tx_download_mutex);
883
- return m_txdownloadman.RecentConfirmedTransactionsFilter ();
884
- }
885
-
886
869
/* *
887
870
* For sending `inv`s to inbound peers, we use a single (exponentially
888
871
* distributed) timer for all peers. If we used a separate timer for each
@@ -2214,40 +2197,6 @@ void PeerManagerImpl::BlockChecked(const CBlock& block, const BlockValidationSta
2214
2197
// Messages
2215
2198
//
2216
2199
2217
-
2218
- bool PeerManagerImpl::AlreadyHaveTx (const GenTxid& gtxid, bool include_reconsiderable)
2219
- {
2220
- AssertLockHeld (m_tx_download_mutex);
2221
-
2222
- auto & m_orphanage = m_txdownloadman.GetOrphanageRef ();
2223
-
2224
- const uint256& hash = gtxid.GetHash ();
2225
-
2226
- if (gtxid.IsWtxid ()) {
2227
- // Normal query by wtxid.
2228
- if (m_orphanage.HaveTx (Wtxid::FromUint256 (hash))) return true ;
2229
- } else {
2230
- // Never query by txid: it is possible that the transaction in the orphanage has the same
2231
- // txid but a different witness, which would give us a false positive result. If we decided
2232
- // not to request the transaction based on this result, an attacker could prevent us from
2233
- // downloading a transaction by intentionally creating a malleated version of it. While
2234
- // only one (or none!) of these transactions can ultimately be confirmed, we have no way of
2235
- // discerning which one that is, so the orphanage can store multiple transactions with the
2236
- // same txid.
2237
- //
2238
- // While we won't query by txid, we can try to "guess" what the wtxid is based on the txid.
2239
- // A non-segwit transaction's txid == wtxid. Query this txid "casted" to a wtxid. This will
2240
- // help us find non-segwit transactions, saving bandwidth, and should have no false positives.
2241
- if (m_orphanage.HaveTx (Wtxid::FromUint256 (hash))) return true ;
2242
- }
2243
-
2244
- if (include_reconsiderable && RecentRejectsReconsiderableFilter ().contains (hash)) return true ;
2245
-
2246
- if (RecentConfirmedTransactionsFilter ().contains (hash)) return true ;
2247
-
2248
- return RecentRejectsFilter ().contains (hash) || m_mempool.exists (gtxid);
2249
- }
2250
-
2251
2200
bool PeerManagerImpl::AlreadyHaveBlock (const uint256& block_hash)
2252
2201
{
2253
2202
return m_chainman.m_blockman .LookupBlockIndex (block_hash) != nullptr ;
@@ -4172,7 +4121,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
4172
4121
return ;
4173
4122
}
4174
4123
const GenTxid gtxid = ToGenTxid (inv);
4175
- const bool fAlreadyHave = AlreadyHaveTx (gtxid, /* include_reconsiderable=*/ true );
4124
+ const bool fAlreadyHave = m_txdownloadman. AlreadyHaveTx (gtxid, /* include_reconsiderable=*/ true );
4176
4125
LogDebug (BCLog::NET, " got inv: %s %s peer=%d\n " , inv.ToString (), fAlreadyHave ? " have" : " new" , pfrom.GetId ());
4177
4126
4178
4127
AddKnownTx (*peer, inv.hash );
@@ -4487,7 +4436,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
4487
4436
// already; and an adversary can already relay us old transactions
4488
4437
// (older than our recency filter) if trying to DoS us, without any need
4489
4438
// for witness malleation.
4490
- if (AlreadyHaveTx (GenTxid::Wtxid (wtxid), /* include_reconsiderable=*/ true )) {
4439
+ if (m_txdownloadman. AlreadyHaveTx (GenTxid::Wtxid (wtxid), /* include_reconsiderable=*/ true )) {
4491
4440
if (pfrom.HasPermission (NetPermissionFlags::ForceRelay)) {
4492
4441
// Always relay transactions received from peers with forcerelay
4493
4442
// permission, even if they were already in the mempool, allowing
@@ -4586,7 +4535,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
4586
4535
AddKnownTx (*peer, parent_txid);
4587
4536
// Exclude m_lazy_recent_rejects_reconsiderable: the missing parent may have been
4588
4537
// previously rejected for being too low feerate. This orphan might CPFP it.
4589
- if (!AlreadyHaveTx (gtxid, /* include_reconsiderable=*/ false )) AddTxAnnouncement (pfrom, gtxid, current_time);
4538
+ if (!m_txdownloadman. AlreadyHaveTx (gtxid, /* include_reconsiderable=*/ false )) AddTxAnnouncement (pfrom, gtxid, current_time);
4590
4539
}
4591
4540
4592
4541
if (m_orphanage.AddTx (ptx, pfrom.GetId ())) {
@@ -6259,7 +6208,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
6259
6208
for (const GenTxid& gtxid : requestable) {
6260
6209
// Exclude m_lazy_recent_rejects_reconsiderable: we may be requesting a missing parent
6261
6210
// that was previously rejected for being too low feerate.
6262
- if (!AlreadyHaveTx (gtxid, /* include_reconsiderable=*/ false )) {
6211
+ if (!m_txdownloadman. AlreadyHaveTx (gtxid, /* include_reconsiderable=*/ false )) {
6263
6212
LogDebug (BCLog::NET, " Requesting %s %s peer=%d\n " , gtxid.IsWtxid () ? " wtx" : " tx" ,
6264
6213
gtxid.GetHash ().ToString (), pto->GetId ());
6265
6214
vGetData.emplace_back (gtxid.IsWtxid () ? MSG_WTX : (MSG_TX | GetFetchFlags (*peer)), gtxid.GetHash ());
0 commit comments