aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-12-16 13:30:48 +0100
committerMarcoFalke <falke.marco@gmail.com>2020-12-16 13:30:55 +0100
commitb440c33179e777bfebb8c12840e06ea691a4868f (patch)
treeb8f283fac0425b08c7ebecb1ffcb8aeacbf2fcd7 /src/net.h
parentdff0f6f753eafd932d7d65fbfa33585f620e8e54 (diff)
parentfee88237e03c21bf81f21098e6b89ecfa5327cee (diff)
downloadbitcoin-b440c33179e777bfebb8c12840e06ea691a4868f.tar.xz
Merge #20477: net: Add unit testing of node eviction logic
fee88237e03c21bf81f21098e6b89ecfa5327cee Assert eviction at >= 29 candidates. Assert non-eviction at <= 20 candidates. (practicalswift) 685c428de0fb63ca6ec1419bb112f07d27bcdf14 test: Add unit testing of node eviction logic (practicalswift) ed73f8cee0d7b7facbd2e8dde24a237f20c48c0c net: 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: ACK fee88237e03c21bf81f21098e6b89ecfa5327cee MarcoFalke: ACK fee88237e03c21bf81f21098e6b89ecfa5327cee 🐼 Tree-SHA512: 0827c35609122ca42bfabb17feaaee35c191ab4dc2e428282af425a6c176eaeaff2789b74a4f7eb4ca6b8cb10603068e90ca800e6ef3bc3904d50e76616f7a2b
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
index 20e356562b..278e539f8d 100644
--- a/src/net.h
+++ b/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