20 using Candidates = std::vector<NodeEvictionCandidate>;
44 c.m_connected = std::chrono::seconds{
c.id};
55 c.m_connected = std::chrono::seconds{
c.id};
57 if (
c.id >= 130 &&
c.id < 240) {
58 c.m_network = NET_ONION;
60 c.m_network = NET_IPV4;
71 c.m_connected = std::chrono::seconds{
c.id};
73 if (
c.id >= 90 &&
c.id < 160) {
74 c.m_network = NET_ONION;
75 }
else if (
c.id >= 170 &&
c.id < 250) {
76 c.m_network = NET_I2P;
78 c.m_network = NET_IPV4;
89 c.m_connected = std::chrono::seconds{
c.id};
90 c.m_is_local = (
c.id == 28 ||
c.id == 47);
91 if (
c.id >= 30 &&
c.id < 47) {
93 }
else if (
c.id >= 24 &&
c.id < 28) {
107 c.m_connected = std::chrono::seconds{
c.id};
108 c.m_is_local = (
c.id >= 55 &&
c.id < 60);
109 if (
c.id >= 70 &&
c.id < 80) {
111 }
else if (
c.id >= 80 &&
c.id < 96) {
125 c.m_connected = std::chrono::seconds{
c.id};
126 c.m_is_local = (
c.id >= 140 &&
c.id < 160);
127 if (
c.id >= 170 &&
c.id < 180) {
129 }
else if (
c.id >= 190 &&
c.id < 240) {
Main entry point to nanobench's benchmarking facility.
void ProtectEvictionCandidatesByRatio(std::vector< NodeEvictionCandidate > &eviction_candidates)
Protect desirable or disadvantaged inbound peers from eviction by ratio.
@ NET_ONION
TOR (v2 or v3)
static void EvictionProtection2Networks250Candidates(benchmark::Bench &bench)
static void EvictionProtection3Networks100Candidates(benchmark::Bench &bench)
static void EvictionProtectionCommon(benchmark::Bench &bench, int num_candidates, std::function< void(NodeEvictionCandidate &)> candidate_setup_fn)
static void EvictionProtection1Networks250Candidates(benchmark::Bench &bench)
static void EvictionProtection3Networks250Candidates(benchmark::Bench &bench)
static void EvictionProtection0Networks250Candidates(benchmark::Bench &bench)
static void EvictionProtection3Networks050Candidates(benchmark::Bench &bench)
std::vector< NodeEvictionCandidate > GetRandomNodeEvictionCandidates(int n_candidates, FastRandomContext &random_context)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.