@@ -894,21 +894,21 @@ static void EraseLastKElements(
894
894
elements.erase (std::remove_if (elements.end () - eraseSize, elements.end (), predicate), elements.end ());
895
895
}
896
896
897
- void ProtectEvictionCandidatesByRatio (std::vector<NodeEvictionCandidate>& vEvictionCandidates )
897
+ void ProtectEvictionCandidatesByRatio (std::vector<NodeEvictionCandidate>& eviction_candidates )
898
898
{
899
899
// Protect the half of the remaining nodes which have been connected the longest.
900
900
// This replicates the non-eviction implicit behavior, and precludes attacks that start later.
901
901
// To favorise the diversity of our peer connections, reserve up to (half + 2) of
902
902
// these protected spots for onion and localhost peers, if any, even if they're not
903
903
// longest uptime overall. This helps protect tor peers, which tend to be otherwise
904
904
// disadvantaged under our eviction criteria.
905
- const size_t initial_size = vEvictionCandidates .size ();
905
+ const size_t initial_size = eviction_candidates .size ();
906
906
const size_t total_protect_size{initial_size / 2 };
907
907
const size_t onion_protect_size = total_protect_size / 2 ;
908
908
909
909
if (onion_protect_size) {
910
910
// Pick out up to 1/4 peers connected via our onion service, sorted by longest uptime.
911
- EraseLastKElements (vEvictionCandidates , CompareOnionTimeConnected, onion_protect_size,
911
+ EraseLastKElements (eviction_candidates , CompareOnionTimeConnected, onion_protect_size,
912
912
[](const NodeEvictionCandidate& n) { return n.m_is_onion ; });
913
913
}
914
914
@@ -918,16 +918,16 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& vEvict
918
918
// to localhost peers, sorted by longest uptime, as manually configured
919
919
// hidden services not using `-bind=addr[:port]=onion` will not be detected
920
920
// as inbound onion connections.
921
- const size_t remaining_tor_slots{onion_protect_size - (initial_size - vEvictionCandidates .size ())};
921
+ const size_t remaining_tor_slots{onion_protect_size - (initial_size - eviction_candidates .size ())};
922
922
const size_t localhost_protect_size{std::max (remaining_tor_slots, localhost_min_protect_size)};
923
- EraseLastKElements (vEvictionCandidates , CompareLocalHostTimeConnected, localhost_protect_size,
923
+ EraseLastKElements (eviction_candidates , CompareLocalHostTimeConnected, localhost_protect_size,
924
924
[](const NodeEvictionCandidate& n) { return n.m_is_local ; });
925
925
}
926
926
927
927
// Calculate how many we removed, and update our total number of peers that
928
928
// we want to protect based on uptime accordingly.
929
- const size_t remaining_to_protect{total_protect_size - (initial_size - vEvictionCandidates .size ())};
930
- EraseLastKElements (vEvictionCandidates , ReverseCompareNodeTimeConnected, remaining_to_protect);
929
+ const size_t remaining_to_protect{total_protect_size - (initial_size - eviction_candidates .size ())};
930
+ EraseLastKElements (eviction_candidates , ReverseCompareNodeTimeConnected, remaining_to_protect);
931
931
}
932
932
933
933
[[nodiscard]] std::optional<NodeId> SelectNodeToEvict (std::vector<NodeEvictionCandidate>&& vEvictionCandidates)
0 commit comments