Bitcoin Core  27.99.0
P2P Digital Currency
Classes | Typedefs | Functions
eviction.h File Reference
#include <node/connection_types.h>
#include <net_permissions.h>
#include <chrono>
#include <cstdint>
#include <optional>
#include <vector>
Include dependency graph for eviction.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  NodeEvictionCandidate
 

Typedefs

typedef int64_t NodeId
 

Functions

std::optional< NodeIdSelectNodeToEvict (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 Documentation

◆ NodeId

typedef int64_t NodeId

Definition at line 16 of file eviction.h.

Function Documentation

◆ ProtectEvictionCandidatesByRatio()

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:

  • 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.

Definition at line 105 of file eviction.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SelectNodeToEvict()

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.

Here is the call graph for this function:
Here is the caller graph for this function: