@@ -226,7 +226,7 @@ struct Peer {
226
226
std::vector<CAddress> m_addrs_to_send;
227
227
/* * Probabilistic filter of addresses that this peer already knows.
228
228
* Used to avoid relaying addresses to this peer more than once. */
229
- const std::unique_ptr<CRollingBloomFilter> m_addr_known;
229
+ std::unique_ptr<CRollingBloomFilter> m_addr_known;
230
230
/* * Whether a getaddr request to this peer is outstanding. */
231
231
bool m_getaddr_sent{false };
232
232
/* * Guards address sending timers. */
@@ -612,6 +612,14 @@ class PeerManagerImpl final : public PeerManager
612
612
* @param[in] vRecv The raw message received
613
613
*/
614
614
void ProcessGetCFCheckPt (CNode& peer, CDataStream& vRecv);
615
+
616
+ /* * Checks if address relay is permitted with peer. Initializes
617
+ * `m_addr_known` bloom filter if needed.
618
+ *
619
+ * @return True if address relay is enabled with peer
620
+ * False if address relay is disallowed
621
+ */
622
+ bool SetupAddressRelay (CNode& node, Peer& peer);
615
623
};
616
624
} // namespace
617
625
@@ -4423,6 +4431,22 @@ class CompareInvMempoolOrder
4423
4431
};
4424
4432
}
4425
4433
4434
+ bool PeerManagerImpl::SetupAddressRelay (CNode& node, Peer& peer)
4435
+ {
4436
+ // We don't participate in addr relay with outbound block-relay-only
4437
+ // connections to prevent providing adversaries with the additional
4438
+ // information of addr traffic to infer the link.
4439
+ if (node.IsBlockOnlyConn ()) return false ;
4440
+
4441
+ if (!RelayAddrsWithPeer (peer)) {
4442
+ // First addr message we have received from the peer, initialize
4443
+ // m_addr_known
4444
+ peer.m_addr_known = std::make_unique<CRollingBloomFilter>(5000 , 0.001 );
4445
+ }
4446
+
4447
+ return true ;
4448
+ }
4449
+
4426
4450
bool PeerManagerImpl::SendMessages (CNode* pto)
4427
4451
{
4428
4452
PeerRef peer = GetPeerRef (pto->GetId ());
0 commit comments