mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
p2p, refactor: improve constness in ProtectEvictionCandidatesByRatio()
This commit is contained in:
parent
4a19f501ab
commit
ec590f1d91
1 changed files with 3 additions and 3 deletions
|
@ -903,7 +903,7 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& vEvict
|
||||||
// longest uptime overall. This helps protect tor peers, which tend to be otherwise
|
// longest uptime overall. This helps protect tor peers, which tend to be otherwise
|
||||||
// disadvantaged under our eviction criteria.
|
// disadvantaged under our eviction criteria.
|
||||||
const size_t initial_size = vEvictionCandidates.size();
|
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;
|
const size_t onion_protect_size = total_protect_size / 2;
|
||||||
|
|
||||||
if (onion_protect_size) {
|
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
|
// Calculate how many we removed, and update our total number of peers that
|
||||||
// we want to protect based on uptime accordingly.
|
// we want to protect based on uptime accordingly.
|
||||||
total_protect_size -= initial_size - vEvictionCandidates.size();
|
const size_t remaining_to_protect{total_protect_size - (initial_size - vEvictionCandidates.size())};
|
||||||
EraseLastKElements(vEvictionCandidates, ReverseCompareNodeTimeConnected, total_protect_size);
|
EraseLastKElements(vEvictionCandidates, ReverseCompareNodeTimeConnected, remaining_to_protect);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::optional<NodeId> SelectNodeToEvict(std::vector<NodeEvictionCandidate>&& vEvictionCandidates)
|
[[nodiscard]] std::optional<NodeId> SelectNodeToEvict(std::vector<NodeEvictionCandidate>&& vEvictionCandidates)
|
||||||
|
|
Loading…
Add table
Reference in a new issue