@@ -1422,7 +1422,7 @@ void PeerLogicValidation::BlockChecked(const CBlock& block, const BlockValidatio
1422
1422
//
1423
1423
1424
1424
1425
- bool static AlreadyHaveTx (const CInv& inv , const CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1425
+ bool static AlreadyHaveTx (const GenTxid& gtxid , const CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1426
1426
{
1427
1427
assert (recentRejects);
1428
1428
if (::ChainActive ().Tip ()->GetBlockHash () != hashRecentRejectsChainTip) {
@@ -1436,19 +1436,19 @@ bool static AlreadyHaveTx(const CInv& inv, const CTxMemPool& mempool) EXCLUSIVE_
1436
1436
1437
1437
{
1438
1438
LOCK (g_cs_orphans);
1439
- if (!inv. IsMsgWtx () && mapOrphanTransactions.count (inv. hash )) {
1439
+ if (!gtxid. IsWtxid () && mapOrphanTransactions.count (gtxid. GetHash () )) {
1440
1440
return true ;
1441
- } else if (inv. IsMsgWtx () && g_orphans_by_wtxid.count (inv. hash )) {
1441
+ } else if (gtxid. IsWtxid () && g_orphans_by_wtxid.count (gtxid. GetHash () )) {
1442
1442
return true ;
1443
1443
}
1444
1444
}
1445
1445
1446
1446
{
1447
1447
LOCK (g_cs_recent_confirmed_transactions);
1448
- if (g_recent_confirmed_transactions->contains (inv. hash )) return true ;
1448
+ if (g_recent_confirmed_transactions->contains (gtxid. GetHash () )) return true ;
1449
1449
}
1450
1450
1451
- return recentRejects->contains (inv. hash ) || mempool.exists (ToGenTxid (inv) );
1451
+ return recentRejects->contains (gtxid. GetHash ()) || mempool.exists (gtxid );
1452
1452
}
1453
1453
1454
1454
bool static AlreadyHaveBlock (const uint256& block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
@@ -2675,7 +2675,8 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
2675
2675
best_block = &inv.hash ;
2676
2676
}
2677
2677
} else {
2678
- bool fAlreadyHave = AlreadyHaveTx (inv, mempool);
2678
+ GenTxid gtxid = ToGenTxid (inv);
2679
+ bool fAlreadyHave = AlreadyHaveTx (gtxid, mempool);
2679
2680
LogPrint (BCLog::NET, " got inv: %s %s peer=%d\n " , inv.ToString (), fAlreadyHave ? " have" : " new" , pfrom.GetId ());
2680
2681
2681
2682
pfrom.AddKnownTx (inv.hash );
@@ -2684,7 +2685,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
2684
2685
pfrom.fDisconnect = true ;
2685
2686
return ;
2686
2687
} else if (!fAlreadyHave && !m_chainman.ActiveChainstate ().IsInitialBlockDownload ()) {
2687
- RequestTx (State (pfrom.GetId ()), ToGenTxid (inv) , current_time);
2688
+ RequestTx (State (pfrom.GetId ()), gtxid , current_time);
2688
2689
}
2689
2690
}
2690
2691
}
@@ -2957,7 +2958,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
2957
2958
// already; and an adversary can already relay us old transactions
2958
2959
// (older than our recency filter) if trying to DoS us, without any need
2959
2960
// for witness malleation.
2960
- if (!AlreadyHaveTx (CInv (MSG_WTX , wtxid), m_mempool) &&
2961
+ if (!AlreadyHaveTx (GenTxid ( /* is_wtxid= */ true , wtxid), m_mempool) &&
2961
2962
AcceptToMemoryPool (m_mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */ , 0 /* nAbsurdFee */ )) {
2962
2963
m_mempool.check (&::ChainstateActive ().CoinsTip ());
2963
2964
RelayTransaction (tx.GetHash (), tx.GetWitnessHash (), m_connman);
@@ -3009,9 +3010,9 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
3009
3010
// wtxidrelay peers.
3010
3011
// Eventually we should replace this with an improved
3011
3012
// protocol for getting all unconfirmed parents.
3012
- CInv _inv (MSG_TX , parent_txid) ;
3013
+ GenTxid gtxid{ /* is_wtxid= */ false , parent_txid} ;
3013
3014
pfrom.AddKnownTx (parent_txid);
3014
- if (!AlreadyHaveTx (_inv , m_mempool)) RequestTx (State (pfrom.GetId ()), ToGenTxid (_inv) , current_time);
3015
+ if (!AlreadyHaveTx (gtxid , m_mempool)) RequestTx (State (pfrom.GetId ()), gtxid , current_time);
3015
3016
}
3016
3017
AddOrphanTx (ptx, pfrom.GetId ());
3017
3018
@@ -4562,7 +4563,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
4562
4563
// processing at a later time, see below)
4563
4564
tx_process_time.erase (tx_process_time.begin ());
4564
4565
CInv inv (gtxid.IsWtxid () ? MSG_WTX : (MSG_TX | GetFetchFlags (*pto)), gtxid.GetHash ());
4565
- if (!AlreadyHaveTx (inv, m_mempool)) {
4566
+ if (!AlreadyHaveTx (ToGenTxid ( inv) , m_mempool)) {
4566
4567
// If this transaction was last requested more than 1 minute ago,
4567
4568
// then request.
4568
4569
const auto last_request_time = GetTxRequestTime (gtxid);
0 commit comments