[#ProtectEvictionCandidatesByRatio]
= ProtectEvictionCandidatesByRatio
:mrdocs:

Protect desirable or disadvantaged inbound peers from eviction by ratio&period;

== Synopsis

Declared in `&lt;node&sol;eviction&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
ProtectEvictionCandidatesByRatio(std::vector&lt;NodeEvictionCandidate&gt;& vEvictionCandidates);
----

== Description

This function protects half of the peers which have been connected the longest, to replicate the non&hyphen;eviction implicit behavior and preclude attacks that start later&period;

Half of these protected spots (1&sol;4 of the total) are reserved for the following categories of peers, sorted by longest uptime, even if they&apos;re not longest uptime overall&colon;

* onion peers connected via our tor control service

* localhost peers, as manually configured hidden services not using `&hyphen;bind&equals;addr&lsqb;&colon;port&rsqb;&equals;onion` will not be detected as inbound onion connections

* I2P peers

* CJDNS peers

This helps protect these privacy network peers, which tend to be otherwise disadvantaged under our eviction criteria for their higher min ping times relative to IPv4&sol;IPv6 peers, and favorise the diversity of peer connections&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *vEvictionCandidates*
| The eviction candidates to filter&semi; protected peers are removed in place&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
