From 1cde8005233d163723d4d5bf1bacf22e6cb7a07e Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Sat, 10 Apr 2021 18:05:47 +0200 Subject: [PATCH] p2p, refactor: rm redundant erase_size calculation in SelectNodeToEvict() as EraseLastKElements() called in the next line performs the same operation. Thanks to Martin Zumsande (lightlike) for seeing this while reviewing. Co-authored-by: Martin Zumsande --- src/net.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 6f9f17ed4ef..901132daa38 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -944,8 +944,7 @@ void ProtectEvictionCandidatesByRatio(std::vector& vEvict // An attacker cannot manipulate this metric without performing useful work. EraseLastKElements(vEvictionCandidates, CompareNodeTXTime, 4); // Protect up to 8 non-tx-relay peers that have sent us novel blocks. - const size_t erase_size = std::min(size_t(8), vEvictionCandidates.size()); - EraseLastKElements(vEvictionCandidates, CompareNodeBlockRelayOnlyTime, erase_size, + EraseLastKElements(vEvictionCandidates, CompareNodeBlockRelayOnlyTime, 8, [](const NodeEvictionCandidate& n) { return !n.fRelayTxes && n.fRelevantServices; }); // Protect 4 nodes that most recently sent us novel blocks.