@@ -894,21 +894,21 @@ static void EraseLastKElements(
894894 elements.erase (std::remove_if (elements.end () - eraseSize, elements.end (), predicate), elements.end ());
895895}
896896
897- void ProtectEvictionCandidatesByRatio (std::vector<NodeEvictionCandidate>& vEvictionCandidates )
897+ void ProtectEvictionCandidatesByRatio (std::vector<NodeEvictionCandidate>& eviction_candidates )
898898{
899899 // Protect the half of the remaining nodes which have been connected the longest.
900900 // This replicates the non-eviction implicit behavior, and precludes attacks that start later.
901901 // To favorise the diversity of our peer connections, reserve up to (half + 2) of
902902 // these protected spots for onion and localhost peers, if any, even if they're not
903903 // longest uptime overall. This helps protect tor peers, which tend to be otherwise
904904 // disadvantaged under our eviction criteria.
905- const size_t initial_size = vEvictionCandidates .size ();
905+ const size_t initial_size = eviction_candidates .size ();
906906 const size_t total_protect_size{initial_size / 2 };
907907 const size_t onion_protect_size = total_protect_size / 2 ;
908908
909909 if (onion_protect_size) {
910910 // 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,
912912 [](const NodeEvictionCandidate& n) { return n.m_is_onion ; });
913913 }
914914
@@ -918,16 +918,16 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& vEvict
918918 // to localhost peers, sorted by longest uptime, as manually configured
919919 // hidden services not using `-bind=addr[:port]=onion` will not be detected
920920 // 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 ())};
922922 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,
924924 [](const NodeEvictionCandidate& n) { return n.m_is_local ; });
925925 }
926926
927927 // Calculate how many we removed, and update our total number of peers that
928928 // 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);
931931}
932932
933933[[nodiscard]] std::optional<NodeId> SelectNodeToEvict (std::vector<NodeEvictionCandidate>&& vEvictionCandidates)
0 commit comments