ProtectEvictionCandidatesByRatio

Protect desirable or disadvantaged inbound peers from eviction by ratio.

Synopsis

Declared in <node/eviction.h>

void
ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& vEvictionCandidates);

Description

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

Half of these protected spots (1/4 of the total) are reserved for the following categories of peers, sorted by longest uptime, even if they're not longest uptime overall:

  • onion peers connected via our tor control service

  • localhost peers, as manually configured hidden services not using -bind=addr[:port]=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/IPv6 peers, and favorise the diversity of peer connections.

Parameters

NameDescription
vEvictionCandidatesThe eviction candidates to filter; protected peers are removed in place.