Page MenuHomePhabricator

[addrman] Specify max addresses and pct when calling GetAddresses()

Authored by PiRK on Wed, Sep 8, 12:17.



Commit description:

CAddrMan.GetAddr() would previously limit the number and percentage of
addresses returned (to ADDRMAN_GETADDR_MAX (1000) and
ADDRMAN_GETADDR_MAX_PCT (23) respectively). Instead, make it the callers
responsibility to specify the maximum addresses and percentage they want

For net_processing, the maximums are MAX_ADDR_TO_SEND (1000) and
MAX_PCT_ADDR_TO_SEND (23). For rpc/net, the maximum is specified by the

PR description:

Currently addrman only allows a maximum of 1000 records or 23% of all records to be returned in a call to GetAddr(). Relax this limit and have the client specify the max records they want. For p2p, behaviour is unchanged (but the rate limiting is set inside net_processing, where it belongs). For RPC, getnodeaddresses can now return the complete addrman, which is helpful for testing and monitoring.

Also add a test-only RPC addpeeraddress, which adds an IP address:port to addrman. This is helpful for testing (eg #18991).

This is a backport of core#19658 [1/3]

Test Plan

ninja all check-all

./src/bitcoin-cli getnodeaddresses 0

Diff Detail

rABC Bitcoin ABC
Lint Not Applicable
Tests Not Applicable