Page MenuHomePhabricator

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

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

Details

Summary

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
returned.

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
client.

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]
https://github.com/bitcoin/bitcoin/pull/19658/commits/f26502e9fc8a669b30717525597e3f468eaecf79

Test Plan

ninja all check-all

./src/bitcoin-cli getnodeaddresses 0