| Pick out the potential block-relay
| only peers, and sort them by last block
| time.
|
| Sort an array by the specified comparator,
| then erase the last K elements where
| predicate is true.
|
| Returns a local address that we should
| advertise to this peer
|
| Is our peer’s addrLocal potentially
| useful as an external IP source?
|
| Protect desirable or disadvantaged
| inbound peers from eviction by ratio.
|
| 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
|
| 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.
|
| Select an inbound peer to evict after
| filtering out (protecting) peers having
| distinct, difficult-to-forge characteristics.
| The protection logic picks out fixed
| numbers of desirable peers per various
| criteria, followed by (mostly) ratios
| of desirable or disadvantaged peers.
| If any eviction candidates remain,
| the selection logic chooses a peer to
| evict.
|