77template <
typename T,
typename Comparator>
100 return n.m_conn_type != ConnectionType::INBOUND;
120 {{
false,
NET_CJDNS, 0}, {
false,
NET_I2P, 0}, {
true,
NET_MAX, 0}, {
false,
NET_ONION, 0}}};
126 return n.is_local ? c.m_is_local : c.m_network == n.id;
149 if (n.count == 0)
continue;
153 return n.is_local ? c.m_is_local : c.m_network == n.id;
225 group.push_back(
node);
226 const auto grouptime{group[0].m_connected};
static bool CompareNodeBlockTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
static void EraseLastKElements(std::vector< T > &elements, Comparator comparator, size_t k, std::function< bool(const NodeEvictionCandidate &)> predicate=[](const NodeEvictionCandidate &n) { return true;})
Sort an array by the specified comparator, then erase the last K elements where predicate is true.
static bool CompareNodeBlockRelayOnlyTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
void ProtectNoBanConnections(std::vector< NodeEvictionCandidate > &eviction_candidates)
static bool ReverseCompareNodeTimeConnected(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
static bool CompareNetGroupKeyed(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
void ProtectEvictionCandidatesByRatio(std::vector< NodeEvictionCandidate > &eviction_candidates)
Protect desirable or disadvantaged inbound peers from eviction by ratio.
std::optional< NodeId > SelectNodeToEvict(std::vector< NodeEvictionCandidate > &&vEvictionCandidates)
Select an inbound peer to evict after filtering out (protecting) peers having distinct,...
static bool CompareNodeTXTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
void ProtectOutboundConnections(std::vector< NodeEvictionCandidate > &eviction_candidates)
static bool ReverseCompareNodeMinPingTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
@ NET_MAX
Dummy value to indicate the number of NET_* constants.
@ NET_ONION
TOR (v2 or v3)
Sort eviction candidates by network/localhost and connection uptime.
CompareNodeNetworkTime(bool is_local, Network network)
bool operator()(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) const
std::chrono::seconds m_last_tx_time
std::chrono::seconds m_connected
std::chrono::seconds m_last_block_time
std::chrono::microseconds m_min_ping_time
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.