Skip to content

Commit 1cde800

Browse files
jonatackmzumsande
andcommitted
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 <[email protected]>
1 parent f66ecea commit 1cde800

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/net.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,7 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& vEvict
944944
// An attacker cannot manipulate this metric without performing useful work.
945945
EraseLastKElements(vEvictionCandidates, CompareNodeTXTime, 4);
946946
// Protect up to 8 non-tx-relay peers that have sent us novel blocks.
947-
const size_t erase_size = std::min(size_t(8), vEvictionCandidates.size());
948-
EraseLastKElements(vEvictionCandidates, CompareNodeBlockRelayOnlyTime, erase_size,
947+
EraseLastKElements(vEvictionCandidates, CompareNodeBlockRelayOnlyTime, 8,
949948
[](const NodeEvictionCandidate& n) { return !n.fRelayTxes && n.fRelevantServices; });
950949

951950
// Protect 4 nodes that most recently sent us novel blocks.

0 commit comments

Comments
 (0)