mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-14 01:25:09 +01:00
Merge #17164: p2p: Avoid allocating memory for addrKnown where we don't need it
b6d2183858Minor refactoring to remove implied m_addr_relay_peer. (User)a552e8477cadded asserts to check m_addr_known when it's used (User)090b75c14bp2p: Avoid allocating memory for addrKnown where we don't need it (User) Pull request description: We should allocate memory for addrKnown filter only for those peers which are expected to participate in address relay. Currently, we do it for all peers (including SPV and block-relay-only), which results in extra RAM where it's not needed. Upd: In future, we would still allow SPVs to ask for addrs, so allocation still will be done by default. However, they will be able to opt-out via [this proposal](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-October/017428.html) and then we could save some more memory. This PR still saves memory for block-relay-only peers immediately after merging. Top commit has no ACKs. Tree-SHA512: e84d93b2615556d466f5ca0e543580fde763911a3bfea3127c493ddfaba8f05c8605cb94ff795d165af542b594400995a2c51338185c298581408687e7812463
This commit is contained in:
@@ -2666,11 +2666,10 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
|
||||
addrBind(addrBindIn),
|
||||
fInbound(fInboundIn),
|
||||
nKeyedNetGroup(nKeyedNetGroupIn),
|
||||
addrKnown(5000, 0.001),
|
||||
// Don't relay addr messages to peers that we connect to as block-relay-only
|
||||
// peers (to prevent adversaries from inferring these links from addr
|
||||
// traffic).
|
||||
m_addr_relay_peer(!block_relay_only),
|
||||
m_addr_known{block_relay_only ? nullptr : MakeUnique<CRollingBloomFilter>(5000, 0.001)},
|
||||
id(idIn),
|
||||
nLocalHostNonce(nLocalHostNonceIn),
|
||||
nLocalServices(nLocalServicesIn),
|
||||
|
||||
Reference in New Issue
Block a user