mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 03:33:32 +01:00
addrman: cap the max_pct to not exceed the maximum number of addresses
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
This commit is contained in:
@@ -812,9 +812,11 @@ nid_type AddrManImpl::GetEntry(bool use_tried, size_t bucket, size_t position) c
|
||||
std::vector<CAddress> AddrManImpl::GetAddr_(size_t max_addresses, size_t max_pct, std::optional<Network> network, const bool filtered) const
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
Assume(max_pct <= 100);
|
||||
|
||||
size_t nNodes = vRandom.size();
|
||||
if (max_pct != 0) {
|
||||
max_pct = std::min(max_pct, size_t{100});
|
||||
nNodes = max_pct * nNodes / 100;
|
||||
}
|
||||
if (max_addresses != 0) {
|
||||
|
||||
Reference in New Issue
Block a user