net_processing: rename RelayTransaction() to better describe what it does
What changed, and why it matters
This commit simply renames a function inside Bitcoin Core from RelayTransaction() to InitiateTxBroadcastToAll(). No behavior changes; the new name is more accurate because the function only queues a transaction for possible later broadcast rather than sending it immediately. It is a code clarity and documentation improvement.
No security action needed. Treat as a normal non-security refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
Pure refactor: PeerManager::RelayTransaction() is renamed to PeerManager::InitiateTxBroadcastToAll() across the interface declaration, implementation, and call sites in net_processing.cpp and node/transaction.cpp. The method body is unchanged. The header comment is updated to clarify that the function enqueues the wtxid into Peer::TxRelay::m_tx_inventory_to_send and that an INV may be sent later depending on timing and mempool state. No logic, locking, network, or consensus changes are present.
Changed components
src/net_processing.cppsrc/net_processing.hsrc/node/transaction.cppInspect captured patch +13 / −8
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 51dcadad..f8b56d55 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -537,7 +537,7 @@ public:
std::vector<node::TxOrphanage::OrphanInfo> GetOrphanTransactions() override EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
PeerManagerInfo GetInfo() const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void SendPings() override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
- void RelayTransaction(const Txid& txid, const Wtxid& wtxid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
+ void InitiateTxBroadcastToAll(const Txid& txid, const Wtxid& wtxid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void SetBestBlock(int height, std::chrono::seconds time) override
{
m_best_height = height;
@@ -1579,7 +1579,7 @@ void PeerManagerImpl::ReattemptInitialBroadcast(CScheduler& scheduler)
CTransactionRef tx = m_mempool.get(txid);
if (tx != nullptr) {
- RelayTransaction(txid, tx->GetWitnessHash());
+ InitiateTxBroadcastToAll(txid, tx->GetWitnessHash());
} else {
m_mempool.RemoveUnbroadcastTx(txid, true);
}
@@ -2124,7 +2124,7 @@ void PeerManagerImpl::SendPings()
for(auto& it : m_peer_map) it.second->m_ping_queued = true;
}
-void PeerManagerImpl::RelayTransaction(const Txid& txid, const Wtxid& wtxid)
+void PeerManagerImpl::InitiateTxBroadcastToAll(const Txid& txid, const Wtxid& wtxid)
{
LOCK(m_peer_mutex);
for(auto& it : m_peer_map) {
@@ -3031,7 +3031,7 @@ void PeerManagerImpl::ProcessValidTx(NodeId nodeid, const CTransactionRef& tx, c
tx->GetWitnessHash().ToString(),
m_mempool.size(), m_mempool.DynamicMemoryUsage() / 1000);
- RelayTransaction(tx->GetHash(), tx->GetWitnessHash());
+ InitiateTxBroadcastToAll(tx->GetHash(), tx->GetWitnessHash());
for (const CTransactionRef& removedTx : replaced_transactions) {
AddToCompactExtraTransactions(removedTx);
@@ -4304,7 +4304,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
} else {
LogInfo("Force relaying tx %s (wtxid=%s) from peer=%d\n",
txid.ToString(), wtxid.ToString(), pfrom.GetId());
- RelayTransaction(txid, wtxid);
+ InitiateTxBroadcastToAll(txid, wtxid);
}
}
diff --git a/src/net_processing.h b/src/net_processing.h
index cf75e8f6..654594aa 100644
--- a/src/net_processing.h
+++ b/src/net_processing.h
@@ -116,8 +116,13 @@ public:
/** Get peer manager info. */
virtual PeerManagerInfo GetInfo() const = 0;
- /** Relay transaction to all peers. */
- virtual void RelayTransaction(const Txid& txid, const Wtxid& wtxid) = 0;
+ /**
+ * 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
+ * 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;
/** Send ping message to all peers */
virtual void SendPings() = 0;
diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp
index f5bd0efe..4f0ee6f7 100644
--- a/src/node/transaction.cpp
+++ b/src/node/transaction.cpp
@@ -133,7 +133,7 @@ TransactionError BroadcastTransaction(NodeContext& node,
case TxBroadcast::MEMPOOL_NO_BROADCAST:
break;
case TxBroadcast::MEMPOOL_AND_BROADCAST_TO_ALL:
- node.peerman->RelayTransaction(txid, wtxid);
+ node.peerman->InitiateTxBroadcastToAll(txid, wtxid);
break;
}
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.