Skip to content

Commit 845e3a3

Browse files
committed
[net processing] Ensure transaction announcements are only queued for fully connected peers
1 parent 38d06e1 commit 845e3a3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/net_processing.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ struct Peer {
295295
std::atomic<std::chrono::seconds> m_last_mempool_req{0s};
296296
/** The next time after which we will send an `inv` message containing
297297
* transaction announcements to this peer. */
298-
std::chrono::microseconds m_next_inv_send_time GUARDED_BY(NetEventsInterface::g_msgproc_mutex){0};
298+
std::chrono::microseconds m_next_inv_send_time GUARDED_BY(m_tx_inventory_mutex){0};
299299

300300
/** Minimum fee rate with which to filter transaction announcements to this node. See BIP133. */
301301
std::atomic<CAmount> m_fee_filter_received{0};
@@ -2011,8 +2011,15 @@ void PeerManagerImpl::RelayTransaction(const uint256& txid, const uint256& wtxid
20112011
auto tx_relay = peer.GetTxRelay();
20122012
if (!tx_relay) continue;
20132013

2014-
const uint256& hash{peer.m_wtxid_relay ? wtxid : txid};
20152014
LOCK(tx_relay->m_tx_inventory_mutex);
2015+
// Only queue transactions for announcement once the version handshake
2016+
// is completed. The time of arrival for these transactions is
2017+
// otherwise at risk of leaking to a spy, if the spy is able to
2018+
// distinguish transactions received during the handshake from the rest
2019+
// in the announcement.
2020+
if (tx_relay->m_next_inv_send_time == 0s) continue;
2021+
2022+
const uint256& hash{peer.m_wtxid_relay ? wtxid : txid};
20162023
if (!tx_relay->m_tx_inventory_known_filter.contains(hash)) {
20172024
tx_relay->m_tx_inventory_to_send.insert(hash);
20182025
}

0 commit comments

Comments
 (0)