HomePhabricator

p2p: Avoid allocating memory for addrKnown where we don't need it

Description

p2p: Avoid allocating memory for addrKnown where we don't need it

Summary:

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 and then we could save some more memory.
This PR still saves memory for block-relay-only peers immediately after merging.

We use std::make_unique instead of MakeUnique (see D2463)

This is a backport of Core PR17164 [1/3]
https://github.com/bitcoin/bitcoin/pull/17164/commits/090b75c14be6b9ba2efe38a17d141c6e6af575cb

Test Plan: ninja all check-all

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D8238

Details

Provenance
User <naumenko.gs@gmail.com>Authored on Nov 3 2020, 11:15
PiRKCommitted on Nov 3 2020, 11:15
abc-botPushed on Nov 3 2020, 11:20
Reviewer
Restricted Owners Package
Differential Revision
D8238: p2p: Avoid allocating memory for addrKnown where we don't need it
Parents
rABCeb6fb28d319f: tests: Add fuzzing harness for V1TransportDeserializer (P2P transport)
Branches
Unknown
Tags
Unknown