Skip to content

Commit c9e8d8f

Browse files
committed
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.
1 parent 02e411e commit c9e8d8f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/net.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,7 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& evicti
940940

941941
while (num_networks != 0 && num_protected < max_protect_by_network) {
942942
const size_t disadvantaged_to_protect{max_protect_by_network - num_protected};
943-
const size_t protect_per_network{
944-
std::max(disadvantaged_to_protect / networks.size(), static_cast<size_t>(1))};
945-
943+
const size_t protect_per_network{std::max(disadvantaged_to_protect / num_networks, static_cast<size_t>(1))};
946944
// Early exit flag if there are no remaining candidates by disadvantaged network.
947945
bool protected_at_least_one{false};
948946

0 commit comments

Comments
 (0)