net_processing: Drop unnecessary txid arg from InitiateTxBroadcastToAll
What changed, and why it matters
This is a small code cleanup change in Bitcoin Core's network transaction broadcasting. It removes an unused transaction ID argument from an internal function called InitiateTxBroadcastToAll, leaving only the witness transaction ID. The function's behavior is unchanged; only its signature and call sites are simplified.
No security action required. This is a routine refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors PeerManager::InitiateTxBroadcastToAll to take only a Wtxid instead of both a Txid and Wtxid. All call sites are updated accordingly. The Txid parameter was not used inside the function implementation, so this is a non-functional cleanup. The header comment is also updated to reflect that the wtxid is queued to inbound and outbound inv backlogs rather than per-peer inventory queues.
Changed components
src/net_processing.cppsrc/net_processing.hsrc/node/transaction.cppInspect captured patch +9 / −9
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 11af703c..5b57c2f8 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -603,7 +603,7 @@ public:
std::vector<PrivateBroadcast::TxBroadcastInfo> GetPrivateBroadcastInfo() const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
std::vector<CTransactionRef> AbortPrivateBroadcast(const uint256& id) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void SendPings() override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
- void InitiateTxBroadcastToAll(const Txid& txid, const Wtxid& wtxid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_inv_to_send_mutex);
+ void InitiateTxBroadcastToAll(const Wtxid& wtxid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_inv_to_send_mutex);
node::TransactionError InitiateTxBroadcastPrivate(const CTransactionRef& tx) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void SetBestBlock(int height, std::chrono::seconds time) override
{
@@ -1713,7 +1713,7 @@ void PeerManagerImpl::ReattemptInitialBroadcast(CScheduler& scheduler)
CTransactionRef tx = m_mempool.get(txid);
if (tx != nullptr) {
- InitiateTxBroadcastToAll(txid, tx->GetWitnessHash());
+ InitiateTxBroadcastToAll(tx->GetWitnessHash());
} else {
m_mempool.RemoveUnbroadcastTx(txid, true);
}
@@ -2460,7 +2460,7 @@ void PeerManagerImpl::ProcessInvBacklog(NodeClock::time_point now, bool backlog_
}
}
-void PeerManagerImpl::InitiateTxBroadcastToAll(const Txid&, const Wtxid& wtxid)
+void PeerManagerImpl::InitiateTxBroadcastToAll(const Wtxid& wtxid)
{
{
LOCK(m_inv_to_send_mutex);
@@ -3372,7 +3372,7 @@ void PeerManagerImpl::ProcessValidTx(NodeId nodeid, const CTransactionRef& tx, c
tx->GetWitnessHash().ToString(),
m_mempool.size(), m_mempool.DynamicMemoryUsage() / 1000);
- InitiateTxBroadcastToAll(tx->GetHash(), tx->GetWitnessHash());
+ InitiateTxBroadcastToAll(tx->GetWitnessHash());
for (const CTransactionRef& removedTx : replaced_transactions) {
AddToCompactExtraTransactions(removedTx);
@@ -4694,7 +4694,7 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string
} else {
LogInfo("Force relaying tx %s (wtxid=%s) from peer=%d\n",
txid.ToString(), wtxid.ToString(), pfrom.GetId());
- InitiateTxBroadcastToAll(txid, wtxid);
+ InitiateTxBroadcastToAll(wtxid);
}
}
diff --git a/src/net_processing.h b/src/net_processing.h
index ff0d2baa..a381a6d8 100644
--- a/src/net_processing.h
+++ b/src/net_processing.h
@@ -152,11 +152,11 @@ public:
/**
* Initiate a transaction broadcast to eligible peers.
- * Queue the witness transaction id to `Peer::TxRelay::m_tx_inventory_to_send`
- * for each peer. Later, depending on `Peer::TxRelay::m_next_inv_send_time` and if
+ * Queue the witness transaction id to the inbound and outbound inv backlogs.
+ * Later, depending on `-txsendrate`, `Peer::TxRelay::m_next_inv_send_time` and if
* the transaction is in the mempool, an `INV` about it may be sent to the peer.
*/
- virtual void InitiateTxBroadcastToAll(const Txid& txid, const Wtxid& wtxid) = 0;
+ virtual void InitiateTxBroadcastToAll(const Wtxid& wtxid) = 0;
/**
* Initiate a private transaction broadcast. This is done
diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp
index e7877c69..d331ae05 100644
--- a/src/node/transaction.cpp
+++ b/src/node/transaction.cpp
@@ -130,7 +130,7 @@ TransactionError BroadcastTransaction(NodeContext& node,
case TxBroadcast::MEMPOOL_NO_BROADCAST:
break;
case TxBroadcast::MEMPOOL_AND_BROADCAST_TO_ALL:
- node.peerman->InitiateTxBroadcastToAll(txid, wtxid);
+ node.peerman->InitiateTxBroadcastToAll(wtxid);
break;
case TxBroadcast::NO_MEMPOOL_PRIVATE_BROADCAST:
return node.peerman->InitiateTxBroadcastPrivate(tx);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.