mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
Merge #19658: [rpc] Allow RPC to fetch all addrman records and add records to addrman
37a480e0cd[net] Add addpeeraddress RPC method (John Newbery)ae8051bbd8[test] Test that getnodeaddresses() can return all known addresses (John Newbery)f26502e9fc[addrman] Specify max addresses and pct when calling GetAddresses() (John Newbery) Pull request 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). ACKs for top commit: naumenkogs: utACK37a480e0cdlaanwj: Code review and lightly manually tested ACK37a480e0cdTree-SHA512: f86dcd410aaebaf6e9ca18ce6f23556e5e4649c1325577213d873aa09967298e65ab2dc19a72670641ae92211a923afda1fe124a82e9d2c1cad73d478ef27fdc
This commit is contained in:
@@ -143,6 +143,8 @@ static constexpr unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60;
|
||||
static constexpr uint32_t MAX_GETCFILTERS_SIZE = 1000;
|
||||
/** Maximum number of cf hashes that may be requested with one getcfheaders. See BIP 157. */
|
||||
static constexpr uint32_t MAX_GETCFHEADERS_SIZE = 2000;
|
||||
/** the maximum percentage of addresses from our addrman to return in response to a getaddr message. */
|
||||
static constexpr size_t MAX_PCT_ADDR_TO_SEND = 23;
|
||||
|
||||
struct COrphanTx {
|
||||
// When modifying, adapt the copy of this definition in tests/DoS_tests.
|
||||
@@ -3521,9 +3523,9 @@ void ProcessMessage(
|
||||
pfrom.vAddrToSend.clear();
|
||||
std::vector<CAddress> vAddr;
|
||||
if (pfrom.HasPermission(PF_ADDR)) {
|
||||
vAddr = connman.GetAddresses();
|
||||
vAddr = connman.GetAddresses(MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND);
|
||||
} else {
|
||||
vAddr = connman.GetAddresses(pfrom.addr.GetNetwork());
|
||||
vAddr = connman.GetAddresses(pfrom.addr.GetNetwork(), MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND);
|
||||
}
|
||||
FastRandomContext insecure_rand;
|
||||
for (const CAddress &addr : vAddr) {
|
||||
|
||||
Reference in New Issue
Block a user