mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
[addrman] Specify max addresses and pct when calling GetAddresses()
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.
This commit is contained in:
11
src/net.h
11
src/net.h
@@ -51,11 +51,8 @@ static const bool DEFAULT_WHITELISTFORCERELAY = false;
|
||||
static const int TIMEOUT_INTERVAL = 20 * 60;
|
||||
/** Run the feeler connection loop once every 2 minutes or 120 seconds. **/
|
||||
static const int FEELER_INTERVAL = 120;
|
||||
/** The maximum number of new addresses to accumulate before announcing. */
|
||||
static const unsigned int MAX_ADDR_TO_SEND = 1000;
|
||||
// TODO: remove ADDRMAN_GETADDR_MAX and let the caller specify this limit with MAX_ADDR_TO_SEND.
|
||||
static_assert(MAX_ADDR_TO_SEND == ADDRMAN_GETADDR_MAX,
|
||||
"Max allowed ADDR message size should be equal to the max number of records returned from AddrMan.");
|
||||
/** The maximum number of addresses from our addrman to return in response to a getaddr message. */
|
||||
static constexpr size_t MAX_ADDR_TO_SEND = 1000;
|
||||
/** Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable). */
|
||||
static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000;
|
||||
/** Maximum length of the user agent string in `version` message */
|
||||
@@ -254,14 +251,14 @@ public:
|
||||
void SetServices(const CService &addr, ServiceFlags nServices);
|
||||
void MarkAddressGood(const CAddress& addr);
|
||||
void AddNewAddresses(const std::vector<CAddress>& vAddr, const CAddress& addrFrom, int64_t nTimePenalty = 0);
|
||||
std::vector<CAddress> GetAddresses();
|
||||
std::vector<CAddress> GetAddresses(size_t max_addresses, size_t max_pct);
|
||||
/**
|
||||
* Cache is used to minimize topology leaks, so it should
|
||||
* be used for all non-trusted calls, for example, p2p.
|
||||
* A non-malicious call (from RPC or a peer with addr permission) should
|
||||
* call the function without a parameter to avoid using the cache.
|
||||
*/
|
||||
std::vector<CAddress> GetAddresses(Network requestor_network);
|
||||
std::vector<CAddress> GetAddresses(Network requestor_network, size_t max_addresses, size_t max_pct);
|
||||
|
||||
// This allows temporarily exceeding m_max_outbound_full_relay, with the goal of finding
|
||||
// a peer that is better than all our current peers.
|
||||
|
||||
Reference in New Issue
Block a user