[net processing] Ensure transaction announcements are only queued for fully connected peers

Github-Pull: #26569
Rebased-From: 845e3a34c4
This commit is contained in:
dergoegge 2022-11-28 16:34:50 +00:00 committed by fanquake
parent 95fded1069
commit e15b306017
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -2007,8 +2007,15 @@ void PeerManagerImpl::RelayTransaction(const uint256& txid, const uint256& wtxid
auto tx_relay = peer.GetTxRelay(); auto tx_relay = peer.GetTxRelay();
if (!tx_relay) continue; if (!tx_relay) continue;
const uint256& hash{peer.m_wtxid_relay ? wtxid : txid};
LOCK(tx_relay->m_tx_inventory_mutex); 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)) { if (!tx_relay->m_tx_inventory_known_filter.contains(hash)) {
tx_relay->m_tx_inventory_to_send.insert(hash); tx_relay->m_tx_inventory_to_send.insert(hash);
} }