Skip to content

Commit 052d9bc

Browse files
committed
net_processing: simplify AlreadyHaveTx args
No need to pass mempool to PeerManagerImpl methods.
1 parent eeac506 commit 052d9bc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/net_processing.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class PeerManagerImpl final : public PeerManager
363363
/** Number of outbound peers with m_chain_sync.m_protect. */
364364
int m_outbound_peers_with_protect_from_disconnect GUARDED_BY(cs_main) = 0;
365365

366-
bool AlreadyHaveTx(const GenTxid& gtxid, const CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
366+
bool AlreadyHaveTx(const GenTxid& gtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
367367

368368
/**
369369
* Filter for transactions that were recently rejected by
@@ -1565,7 +1565,7 @@ void PeerManagerImpl::BlockChecked(const CBlock& block, const BlockValidationSta
15651565
//
15661566

15671567

1568-
bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid, const CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1568+
bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
15691569
{
15701570
assert(recentRejects);
15711571
if (::ChainActive().Tip()->GetBlockHash() != hashRecentRejectsChainTip) {
@@ -1593,7 +1593,7 @@ bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid, const CTxMemPool& memp
15931593
if (m_recent_confirmed_transactions->contains(hash)) return true;
15941594
}
15951595

1596-
return recentRejects->contains(hash) || mempool.exists(gtxid);
1596+
return recentRejects->contains(hash) || m_mempool.exists(gtxid);
15971597
}
15981598

15991599
bool static AlreadyHaveBlock(const uint256& block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
@@ -2903,7 +2903,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
29032903
}
29042904
} else if (inv.IsGenTxMsg()) {
29052905
const GenTxid gtxid = ToGenTxid(inv);
2906-
const bool fAlreadyHave = AlreadyHaveTx(gtxid, m_mempool);
2906+
const bool fAlreadyHave = AlreadyHaveTx(gtxid);
29072907
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
29082908

29092909
pfrom.AddKnownTx(inv.hash);
@@ -3184,7 +3184,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
31843184
// already; and an adversary can already relay us old transactions
31853185
// (older than our recency filter) if trying to DoS us, without any need
31863186
// for witness malleation.
3187-
if (AlreadyHaveTx(GenTxid(/* is_wtxid=*/true, wtxid), m_mempool)) {
3187+
if (AlreadyHaveTx(GenTxid(/* is_wtxid=*/true, wtxid))) {
31883188
if (pfrom.HasPermission(PF_FORCERELAY)) {
31893189
// Always relay transactions received from peers with forcerelay
31903190
// permission, even if they were already in the mempool, allowing
@@ -3263,7 +3263,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
32633263
// protocol for getting all unconfirmed parents.
32643264
const GenTxid gtxid{/* is_wtxid=*/false, parent_txid};
32653265
pfrom.AddKnownTx(parent_txid);
3266-
if (!AlreadyHaveTx(gtxid, m_mempool)) AddTxAnnouncement(pfrom, gtxid, current_time);
3266+
if (!AlreadyHaveTx(gtxid)) AddTxAnnouncement(pfrom, gtxid, current_time);
32673267
}
32683268
AddOrphanTx(ptx, pfrom.GetId());
32693269

@@ -4804,7 +4804,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
48044804
entry.second.GetHash().ToString(), entry.first);
48054805
}
48064806
for (const GenTxid& gtxid : requestable) {
4807-
if (!AlreadyHaveTx(gtxid, m_mempool)) {
4807+
if (!AlreadyHaveTx(gtxid)) {
48084808
LogPrint(BCLog::NET, "Requesting %s %s peer=%d\n", gtxid.IsWtxid() ? "wtx" : "tx",
48094809
gtxid.GetHash().ToString(), pto->GetId());
48104810
vGetData.emplace_back(gtxid.IsWtxid() ? MSG_WTX : (MSG_TX | GetFetchFlags(*pto)), gtxid.GetHash());

0 commit comments

Comments
 (0)