10#include <test/util/net.h>
11#include <test/util/setup_common.h>
20 using Candidates = std::vector<NodeEvictionCandidate>;
42 c.m_connected = std::chrono::seconds{
c.id};
50 c.m_connected = std::chrono::seconds{
c.id};
53 if (
c.id >= 130 &&
c.id < 240) {
54 c.m_network = NET_ONION;
56 c.m_network = NET_IPV4;
64 c.m_connected = std::chrono::seconds{
c.id};
66 if (
c.id >= 90 &&
c.id < 160) {
68 c.m_network = NET_ONION;
69 }
else if (
c.id >= 170 &&
c.id < 250) {
71 c.m_network = NET_I2P;
73 c.m_network = NET_IPV4;
81 c.m_connected = std::chrono::seconds{
c.id};
83 c.m_is_local = (
c.id == 28 ||
c.id == 47);
84 if (
c.id >= 30 &&
c.id < 47) {
87 }
else if (
c.id >= 24 &&
c.id < 28) {
99 c.m_connected = std::chrono::seconds{
c.id};
101 c.m_is_local = (
c.id >= 55 &&
c.id < 60);
102 if (
c.id >= 70 &&
c.id < 80) {
105 }
else if (
c.id >= 80 &&
c.id < 96) {
117 c.m_connected = std::chrono::seconds{
c.id};
119 c.m_is_local = (
c.id >= 140 &&
c.id < 160);
120 if (
c.id >= 170 &&
c.id < 180) {
123 }
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)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...