@@ -477,9 +477,19 @@ class PeerManagerImpl final : public PeerManager
477
477
* Filter for transactions that have been recently confirmed.
478
478
* We use this to avoid requesting transactions that have already been
479
479
* confirnmed.
480
+ *
481
+ * Blocks don't typically have more than 4000 transactions, so this should
482
+ * be at least six blocks (~1 hr) worth of transactions that we can store,
483
+ * inserting both a txid and wtxid for every observed transaction.
484
+ * If the number of transactions appearing in a block goes up, or if we are
485
+ * seeing getdata requests more than an hour after initial announcement, we
486
+ * can increase this number.
487
+ * The false positive rate of 1/1M should come out to less than 1
488
+ * transaction per day that would be inadvertently ignored (which is the
489
+ * same probability that we have in the reject filter).
480
490
*/
481
491
Mutex m_recent_confirmed_transactions_mutex;
482
- std::unique_ptr< CRollingBloomFilter> m_recent_confirmed_transactions GUARDED_BY (m_recent_confirmed_transactions_mutex);
492
+ CRollingBloomFilter m_recent_confirmed_transactions GUARDED_BY (m_recent_confirmed_transactions_mutex){ 48'000 , 0.000'001 } ;
483
493
484
494
/* * Have we requested this block from a peer */
485
495
bool IsBlockRequested (const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
@@ -1396,17 +1406,6 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn
1396
1406
m_mempool(pool),
1397
1407
m_ignore_incoming_txs(ignore_incoming_txs)
1398
1408
{
1399
- // Blocks don't typically have more than 4000 transactions, so this should
1400
- // be at least six blocks (~1 hr) worth of transactions that we can store,
1401
- // inserting both a txid and wtxid for every observed transaction.
1402
- // If the number of transactions appearing in a block goes up, or if we are
1403
- // seeing getdata requests more than an hour after initial announcement, we
1404
- // can increase this number.
1405
- // The false positive rate of 1/1M should come out to less than 1
1406
- // transaction per day that would be inadvertently ignored (which is the
1407
- // same probability that we have in the reject filter).
1408
- m_recent_confirmed_transactions.reset (new CRollingBloomFilter (48000 , 0.000001 ));
1409
-
1410
1409
// Stale tip checking and peer eviction are on two different timers, but we
1411
1410
// don't want them to get out of sync due to drift in the scheduler, so we
1412
1411
// combine them in one function and schedule at the quicker (peer-eviction)
@@ -1432,9 +1431,9 @@ void PeerManagerImpl::BlockConnected(const std::shared_ptr<const CBlock>& pblock
1432
1431
{
1433
1432
LOCK (m_recent_confirmed_transactions_mutex);
1434
1433
for (const auto & ptx : pblock->vtx ) {
1435
- m_recent_confirmed_transactions-> insert (ptx->GetHash ());
1434
+ m_recent_confirmed_transactions. insert (ptx->GetHash ());
1436
1435
if (ptx->GetHash () != ptx->GetWitnessHash ()) {
1437
- m_recent_confirmed_transactions-> insert (ptx->GetWitnessHash ());
1436
+ m_recent_confirmed_transactions. insert (ptx->GetWitnessHash ());
1438
1437
}
1439
1438
}
1440
1439
}
@@ -1458,7 +1457,7 @@ void PeerManagerImpl::BlockDisconnected(const std::shared_ptr<const CBlock> &blo
1458
1457
// presumably the most common case of relaying a confirmed transaction
1459
1458
// should be just after a new block containing it is found.
1460
1459
LOCK (m_recent_confirmed_transactions_mutex);
1461
- m_recent_confirmed_transactions-> reset ();
1460
+ m_recent_confirmed_transactions. reset ();
1462
1461
}
1463
1462
1464
1463
// All of the following cache a recent block, and are protected by cs_most_recent_block
@@ -1613,7 +1612,7 @@ bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid)
1613
1612
1614
1613
{
1615
1614
LOCK (m_recent_confirmed_transactions_mutex);
1616
- if (m_recent_confirmed_transactions-> contains (hash)) return true ;
1615
+ if (m_recent_confirmed_transactions. contains (hash)) return true ;
1617
1616
}
1618
1617
1619
1618
return m_recent_rejects.contains (hash) || m_mempool.exists (gtxid);
0 commit comments