[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