Bitcoin Core 28.99.0
P2P Digital Currency
|
#include <node/connection_types.h>
#include <net_permissions.h>
#include <chrono>
#include <cstdint>
#include <optional>
#include <vector>
Go to the source code of this file.
Classes | |
struct | NodeEvictionCandidate |
Typedefs | |
typedef int64_t | NodeId |
Functions | |
std::optional< NodeId > | SelectNodeToEvict (std::vector< NodeEvictionCandidate > &&vEvictionCandidates) |
Select an inbound peer to evict after filtering out (protecting) peers having distinct, difficult-to-forge characteristics. More... | |
void | ProtectEvictionCandidatesByRatio (std::vector< NodeEvictionCandidate > &vEvictionCandidates) |
Protect desirable or disadvantaged inbound peers from eviction by ratio. More... | |
typedef int64_t NodeId |
Definition at line 16 of file eviction.h.
void ProtectEvictionCandidatesByRatio | ( | std::vector< NodeEvictionCandidate > & | vEvictionCandidates | ) |
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:
-bind=addr[:port]=onion
will not be detected as inbound onion connectionsThis 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.
Definition at line 105 of file eviction.cpp.
std::optional< NodeId > SelectNodeToEvict | ( | std::vector< NodeEvictionCandidate > && | vEvictionCandidates | ) |
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.
Definition at line 178 of file eviction.cpp.