diff options
author | dergoegge <n.goeggi@gmail.com> | 2022-11-28 16:34:50 +0000 |
---|---|---|
committer | dergoegge <n.goeggi@gmail.com> | 2022-11-29 13:54:50 +0000 |
commit | 845e3a34c49abcc634b5a10ccdd6b10fb4fcf449 (patch) | |
tree | 80a52347459c57e1d036071cca69fa6f5b22e1e4 | |
parent | 38d06e1561013f4ca845fd5ba6ffcc64de67f9c0 (diff) |
[net processing] Ensure transaction announcements are only queued for fully connected peers
-rw-r--r-- | src/net_processing.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 0d5be42e0e..70e7eb85d8 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -295,7 +295,7 @@ struct Peer { std::atomic<std::chrono::seconds> m_last_mempool_req{0s}; /** The next time after which we will send an `inv` message containing * transaction announcements to this peer. */ - std::chrono::microseconds m_next_inv_send_time GUARDED_BY(NetEventsInterface::g_msgproc_mutex){0}; + std::chrono::microseconds m_next_inv_send_time GUARDED_BY(m_tx_inventory_mutex){0}; /** Minimum fee rate with which to filter transaction announcements to this node. See BIP133. */ std::atomic<CAmount> m_fee_filter_received{0}; @@ -2011,8 +2011,15 @@ void PeerManagerImpl::RelayTransaction(const uint256& txid, const uint256& wtxid auto tx_relay = peer.GetTxRelay(); if (!tx_relay) continue; - const uint256& hash{peer.m_wtxid_relay ? wtxid : txid}; LOCK(tx_relay->m_tx_inventory_mutex); + // Only queue transactions for announcement once the version handshake + // is completed. The time of arrival for these transactions is + // otherwise at risk of leaking to a spy, if the spy is able to + // distinguish transactions received during the handshake from the rest + // in the announcement. + if (tx_relay->m_next_inv_send_time == 0s) continue; + + const uint256& hash{peer.m_wtxid_relay ? wtxid : txid}; if (!tx_relay->m_tx_inventory_known_filter.contains(hash)) { tx_relay->m_tx_inventory_to_send.insert(hash); } |