@@ -362,10 +362,9 @@ class PeerManagerImpl final : public PeerManager
362
362
363
363
/* * Number of outbound peers with m_chain_sync.m_protect. */
364
364
int m_outbound_peers_with_protect_from_disconnect GUARDED_BY (cs_main) = 0;
365
- };
366
- } // namespace
367
365
368
- namespace {
366
+ bool AlreadyHaveTx (const GenTxid& gtxid, const CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
367
+
369
368
/* *
370
369
* Filter for transactions that were recently rejected by
371
370
* AcceptToMemoryPool. These are not rerequested until the chain tip
@@ -408,9 +407,12 @@ namespace {
408
407
* We use this to avoid requesting transactions that have already been
409
408
* confirnmed.
410
409
*/
411
- Mutex g_cs_recent_confirmed_transactions;
412
- std::unique_ptr<CRollingBloomFilter> g_recent_confirmed_transactions GUARDED_BY (g_cs_recent_confirmed_transactions);
410
+ Mutex m_recent_confirmed_transactions_mutex;
411
+ std::unique_ptr<CRollingBloomFilter> m_recent_confirmed_transactions GUARDED_BY (m_recent_confirmed_transactions_mutex);
412
+ };
413
+ } // namespace
413
414
415
+ namespace {
414
416
/* * Blocks that are in flight, and that are in the queue to be downloaded. */
415
417
struct QueuedBlock {
416
418
uint256 hash;
@@ -1344,7 +1346,7 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn
1344
1346
// The false positive rate of 1/1M should come out to less than 1
1345
1347
// transaction per day that would be inadvertently ignored (which is the
1346
1348
// same probability that we have in the reject filter).
1347
- g_recent_confirmed_transactions .reset (new CRollingBloomFilter (48000 , 0.000001 ));
1349
+ m_recent_confirmed_transactions .reset (new CRollingBloomFilter (48000 , 0.000001 ));
1348
1350
1349
1351
// Stale tip checking and peer eviction are on two different timers, but we
1350
1352
// don't want them to get out of sync due to drift in the scheduler, so we
@@ -1397,11 +1399,11 @@ void PeerManagerImpl::BlockConnected(const std::shared_ptr<const CBlock>& pblock
1397
1399
g_last_tip_update = GetTime ();
1398
1400
}
1399
1401
{
1400
- LOCK (g_cs_recent_confirmed_transactions );
1402
+ LOCK (m_recent_confirmed_transactions_mutex );
1401
1403
for (const auto & ptx : pblock->vtx ) {
1402
- g_recent_confirmed_transactions ->insert (ptx->GetHash ());
1404
+ m_recent_confirmed_transactions ->insert (ptx->GetHash ());
1403
1405
if (ptx->GetHash () != ptx->GetWitnessHash ()) {
1404
- g_recent_confirmed_transactions ->insert (ptx->GetWitnessHash ());
1406
+ m_recent_confirmed_transactions ->insert (ptx->GetWitnessHash ());
1405
1407
}
1406
1408
}
1407
1409
}
@@ -1424,8 +1426,8 @@ void PeerManagerImpl::BlockDisconnected(const std::shared_ptr<const CBlock> &blo
1424
1426
// block's worth of transactions in it, but that should be fine, since
1425
1427
// presumably the most common case of relaying a confirmed transaction
1426
1428
// should be just after a new block containing it is found.
1427
- LOCK (g_cs_recent_confirmed_transactions );
1428
- g_recent_confirmed_transactions ->reset ();
1429
+ LOCK (m_recent_confirmed_transactions_mutex );
1430
+ m_recent_confirmed_transactions ->reset ();
1429
1431
}
1430
1432
1431
1433
// All of the following cache a recent block, and are protected by cs_most_recent_block
@@ -1563,7 +1565,7 @@ void PeerManagerImpl::BlockChecked(const CBlock& block, const BlockValidationSta
1563
1565
//
1564
1566
1565
1567
1566
- bool static AlreadyHaveTx (const GenTxid& gtxid, const CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1568
+ bool PeerManagerImpl:: AlreadyHaveTx (const GenTxid& gtxid, const CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1567
1569
{
1568
1570
assert (recentRejects);
1569
1571
if (::ChainActive ().Tip ()->GetBlockHash () != hashRecentRejectsChainTip) {
@@ -1587,8 +1589,8 @@ bool static AlreadyHaveTx(const GenTxid& gtxid, const CTxMemPool& mempool) EXCLU
1587
1589
}
1588
1590
1589
1591
{
1590
- LOCK (g_cs_recent_confirmed_transactions );
1591
- if (g_recent_confirmed_transactions ->contains (hash)) return true ;
1592
+ LOCK (m_recent_confirmed_transactions_mutex );
1593
+ if (m_recent_confirmed_transactions ->contains (hash)) return true ;
1592
1594
}
1593
1595
1594
1596
return recentRejects->contains (hash) || mempool.exists (gtxid);
0 commit comments