diff options
author | Jon Atack <jon@atack.com> | 2021-04-10 18:05:47 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2021-06-11 12:26:59 +0200 |
commit | 1cde8005233d163723d4d5bf1bacf22e6cb7a07e (patch) | |
tree | 5724bbaa1b931f88f9053225f61836d0dc9f5790 /src/net.cpp | |
parent | f66eceaecf464bfab5e19f3ca8fe680d8a6aa2e1 (diff) | |
download | bitcoin-1cde8005233d163723d4d5bf1bacf22e6cb7a07e.tar.xz |
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 <mzumsande@gmail.com>
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp index 6f9f17ed4e..901132daa3 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -944,8 +944,7 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& 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. |