mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge #20477: net: Add unit testing of node eviction logic
fee88237e0Assert eviction at >= 29 candidates. Assert non-eviction at <= 20 candidates. (practicalswift)685c428de0test: Add unit testing of node eviction logic (practicalswift)ed73f8cee0net: Move eviction node selection logic to SelectNodeToEvict(...) (practicalswift) Pull request description: Add unit testing of node eviction logic. Closes #19966. ACKs for top commit: jonatack: ACKfee88237e0MarcoFalke: ACKfee88237e0🐼 Tree-SHA512: 0827c35609122ca42bfabb17feaaee35c191ab4dc2e428282af425a6c176eaeaff2789b74a4f7eb4ca6b8cb10603068e90ca800e6ef3bc3904d50e76616f7a2b
This commit is contained in:
18
src/net.h
18
src/net.h
@@ -33,6 +33,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
class CScheduler;
|
||||
class CNode;
|
||||
@@ -1239,4 +1240,21 @@ inline std::chrono::microseconds PoissonNextSend(std::chrono::microseconds now,
|
||||
return std::chrono::microseconds{PoissonNextSend(now.count(), average_interval.count())};
|
||||
}
|
||||
|
||||
struct NodeEvictionCandidate
|
||||
{
|
||||
NodeId id;
|
||||
int64_t nTimeConnected;
|
||||
int64_t nMinPingUsecTime;
|
||||
int64_t nLastBlockTime;
|
||||
int64_t nLastTXTime;
|
||||
bool fRelevantServices;
|
||||
bool fRelayTxes;
|
||||
bool fBloomFilter;
|
||||
uint64_t nKeyedNetGroup;
|
||||
bool prefer_evict;
|
||||
bool m_is_local;
|
||||
};
|
||||
|
||||
[[nodiscard]] Optional<NodeId> SelectNodeToEvict(std::vector<NodeEvictionCandidate>&& vEvictionCandidates);
|
||||
|
||||
#endif // BITCOIN_NET_H
|
||||
|
||||
Reference in New Issue
Block a user