Page MenuHomePhabricator

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

Authored by PiRK on Nov 2 2020, 16:39.

Details

Reviewers
Fabien
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rABC59d4627bec11: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Nov 2 2020, 16:39
PiRK requested review of this revision.Nov 2 2020, 16:39
This revision is now accepted and ready to land.Nov 3 2020, 10:37