diff options
author | Jon Atack <jon@atack.com> | 2021-06-10 10:45:17 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2021-06-13 20:15:43 +0200 |
commit | ec590f1d91325404383d74098a5b42a2cd67dad9 (patch) | |
tree | addf6b125d47932892135aadcdbd124e6fe54688 | |
parent | 4a19f501abac4adb476a6f2a30dfdf1a35892ccc (diff) |
p2p, refactor: improve constness in ProtectEvictionCandidatesByRatio()
-rw-r--r-- | src/net.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp index 901132daa3..f1fd9b6c91 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -903,7 +903,7 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& vEvict // longest uptime overall. This helps protect tor peers, which tend to be otherwise // disadvantaged under our eviction criteria. const size_t initial_size = vEvictionCandidates.size(); - size_t total_protect_size = initial_size / 2; + const size_t total_protect_size{initial_size / 2}; const size_t onion_protect_size = total_protect_size / 2; if (onion_protect_size) { @@ -926,8 +926,8 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& vEvict // Calculate how many we removed, and update our total number of peers that // we want to protect based on uptime accordingly. - total_protect_size -= initial_size - vEvictionCandidates.size(); - EraseLastKElements(vEvictionCandidates, ReverseCompareNodeTimeConnected, total_protect_size); + const size_t remaining_to_protect{total_protect_size - (initial_size - vEvictionCandidates.size())}; + EraseLastKElements(vEvictionCandidates, ReverseCompareNodeTimeConnected, remaining_to_protect); } [[nodiscard]] std::optional<NodeId> SelectNodeToEvict(std::vector<NodeEvictionCandidate>&& vEvictionCandidates) |