HomePhabricator

[net processing] Refactor MaybeSendAddr()

Description

[net processing] Refactor MaybeSendAddr()

Summary:
Changes to make MaybeSendAddr simpler and easier to maintain/update:

  • assert invariant that node.vAddrToSend.size() can never exceed MAX_ADDR_TO_SEND
  • erase known addresses from vAddrToSend in one pass
  • no check for (vAddr.size() >= MAX_ADDR_TO_SEND) during iteration, since vAddr can never exceed MAX_ADDR_TO_SEND.

Note: we used GetMaxAddrToSend() instead of MAX_ADDR_TO_SEND because it can be overriden by the -maxaddrtosend command line option (D10823]

This concludes backport of core#21236 [6/6]
https://github.com/bitcoin/bitcoin/pull/21236/commits/935d4889228e7e361c8b0020761fa0e08a55fb48

Depends on D10919

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
John Newbery <john@johnnewbery.com>Authored on Jul 9 2020, 10:32
PiRKCommitted on Jan 28 2022, 10:23
PiRKPushed on Jan 28 2022, 10:23
Reviewer
Restricted Project
Differential Revision
D10920: [net processing] Refactor MaybeSendAddr()
Parents
rABC4521689ee985: [net processing] Refactor MaybeSendAddr() - early exits
Branches
Unknown
Tags
Unknown