@@ -1434,21 +1434,23 @@ bool static AlreadyHaveTx(const GenTxid& gtxid, const CTxMemPool& mempool) EXCLU
1434
1434
recentRejects->reset ();
1435
1435
}
1436
1436
1437
+ const uint256& hash = gtxid.GetHash ();
1438
+
1437
1439
{
1438
1440
LOCK (g_cs_orphans);
1439
- if (!gtxid.IsWtxid () && mapOrphanTransactions.count (gtxid. GetHash () )) {
1441
+ if (!gtxid.IsWtxid () && mapOrphanTransactions.count (hash )) {
1440
1442
return true ;
1441
- } else if (gtxid.IsWtxid () && g_orphans_by_wtxid.count (gtxid. GetHash () )) {
1443
+ } else if (gtxid.IsWtxid () && g_orphans_by_wtxid.count (hash )) {
1442
1444
return true ;
1443
1445
}
1444
1446
}
1445
1447
1446
1448
{
1447
1449
LOCK (g_cs_recent_confirmed_transactions);
1448
- if (g_recent_confirmed_transactions->contains (gtxid. GetHash () )) return true ;
1450
+ if (g_recent_confirmed_transactions->contains (hash )) return true ;
1449
1451
}
1450
1452
1451
- return recentRejects->contains (gtxid. GetHash () ) || mempool.exists (gtxid);
1453
+ return recentRejects->contains (hash ) || mempool.exists (gtxid);
1452
1454
}
1453
1455
1454
1456
bool static AlreadyHaveBlock (const uint256& block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
@@ -2645,8 +2647,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
2645
2647
const auto current_time = GetTime<std::chrono::microseconds>();
2646
2648
uint256* best_block{nullptr };
2647
2649
2648
- for (CInv &inv : vInv)
2649
- {
2650
+ for (CInv& inv : vInv) {
2650
2651
if (interruptMsgProc) return ;
2651
2652
2652
2653
// Ignore INVs that don't match wtxidrelay setting.
@@ -2659,7 +2660,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
2659
2660
}
2660
2661
2661
2662
if (inv.IsMsgBlk ()) {
2662
- bool fAlreadyHave = AlreadyHaveBlock (inv.hash );
2663
+ const bool fAlreadyHave = AlreadyHaveBlock (inv.hash );
2663
2664
LogPrint (BCLog::NET, " got inv: %s %s peer=%d\n " , inv.ToString (), fAlreadyHave ? " have" : " new" , pfrom.GetId ());
2664
2665
2665
2666
UpdateBlockAvailability (pfrom.GetId (), inv.hash );
@@ -2672,8 +2673,8 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
2672
2673
best_block = &inv.hash ;
2673
2674
}
2674
2675
} else {
2675
- GenTxid gtxid = ToGenTxid (inv);
2676
- bool fAlreadyHave = AlreadyHaveTx (gtxid, mempool);
2676
+ const GenTxid gtxid = ToGenTxid (inv);
2677
+ const bool fAlreadyHave = AlreadyHaveTx (gtxid, mempool);
2677
2678
LogPrint (BCLog::NET, " got inv: %s %s peer=%d\n " , inv.ToString (), fAlreadyHave ? " have" : " new" , pfrom.GetId ());
2678
2679
2679
2680
pfrom.AddKnownTx (inv.hash );
@@ -3007,7 +3008,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
3007
3008
// wtxidrelay peers.
3008
3009
// Eventually we should replace this with an improved
3009
3010
// protocol for getting all unconfirmed parents.
3010
- GenTxid gtxid{/* is_wtxid=*/ false , parent_txid};
3011
+ const GenTxid gtxid{/* is_wtxid=*/ false , parent_txid};
3011
3012
pfrom.AddKnownTx (parent_txid);
3012
3013
if (!AlreadyHaveTx (gtxid, m_mempool)) RequestTx (State (pfrom.GetId ()), gtxid, current_time);
3013
3014
}
0 commit comments