77template <
typename T,
typename Comparator>
112 {{
false,
NET_CJDNS, 0}, {
false,
NET_I2P, 0}, {
true,
NET_MAX, 0}, {
false,
NET_ONION, 0}}};
118 return n.is_local ? c.m_is_local : c.m_network == n.id;
141 if (n.count == 0)
continue;
145 return n.is_local ? c.m_is_local : c.m_network == n.id;
216 group.push_back(
node);
217 const auto grouptime{group[0].m_connected};
@ INBOUND
Inbound connections are those initiated by a peer.
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::time_point< NodeClock > time_point
static constexpr time_point epoch
std::chrono::seconds m_last_tx_time
NodeClock::duration m_min_ping_time
std::chrono::seconds m_last_block_time
ConnectionType m_conn_type
NodeClock::time_point m_connected
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.