aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-07-06 17:01:15 +0200
committerJon Atack <jon@atack.com>2021-07-08 12:28:38 +0200
commitc9e8d8f9b168dec2bc7b845da38449e96708cf8e (patch)
tree71c7fc6042432899fd99324faf26257e8082d1c1 /src/net.cpp
parent02e411ec456af80d1da76085a814c68bb3aca6de (diff)
downloadbitcoin-c9e8d8f9b168dec2bc7b845da38449e96708cf8e.tar.xz
p2p: process more candidates per protection iteration
for the usual case when some of the protected networks don't have eviction candidates, to reduce the number of iterations in ProtectEvictionCandidatesByRatio(). Picks up an idea in ef411cd2 that I had dropped.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 1611b1a24b..9567e2b0cf 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -940,9 +940,7 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& evicti
while (num_networks != 0 && num_protected < max_protect_by_network) {
const size_t disadvantaged_to_protect{max_protect_by_network - num_protected};
- const size_t protect_per_network{
- std::max(disadvantaged_to_protect / networks.size(), static_cast<size_t>(1))};
-
+ const size_t protect_per_network{std::max(disadvantaged_to_protect / num_networks, static_cast<size_t>(1))};
// Early exit flag if there are no remaining candidates by disadvantaged network.
bool protected_at_least_one{false};