This PR splits of the first couple commits from #25268 that move the inbound eviction logic from net.{h,cpp}
to eviction.{h,cpp}
.
Please look at #25268 for motivation and conceptual review.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
44@@ -45,6 +45,12 @@ static inline constexpr NetPermissionFlags operator|(NetPermissionFlags a, NetPe
45 return static_cast<NetPermissionFlags>(static_cast<t>(a) | static_cast<t>(b));
46 }
47
48+static inline constexpr NetPermissionFlags operator&(NetPermissionFlags a, NetPermissionFlags b)
49+{
50+ using t = typename std::underlying_type<NetPermissionFlags>::type;
51+ return static_cast<NetPermissionFlags>(static_cast<t>(a) & static_cast<t>(b));
NetPermissionFlags{...}
instead of static_cast?
347@@ -346,8 +348,10 @@ libbitcoin_node_a_SOURCES = \
348 blockfilter.cpp \
349 chain.cpp \
350 consensus/tx_verify.cpp \
351+ connection_types.cpp \
352 dbwrapper.cpp \
353 deploymentstatus.cpp \
354+ eviction.cpp \
node
, as the lib is called libbitcoin_node_a_SOURCES
connection_types.cpp|h
.
26+ bool fBloomFilter;
27+ uint64_t nKeyedNetGroup;
28+ bool prefer_evict;
29+ bool m_is_local;
30+ Network m_network;
31+ NetPermissionFlags m_perm_flags;
NetPermissionFlags::NoBan
bit is set. Perhaps this could be replaced with a m_noban
bool?
27+ uint64_t nKeyedNetGroup;
28+ bool prefer_evict;
29+ bool m_is_local;
30+ Network m_network;
31+ NetPermissionFlags m_perm_flags;
32+ ConnectionType m_conn_type;
Likewise, only one bit of information is actually needed by the eviction logic. Would it be better to replace this with an m_inbound
boolean?
Perhaps the eviction logic will be changed in future to use more permissions and connection types, but it’ll be easy enough to change these internal interfaces when that happens.
Left this as is because the outbound eviction logic that gets moved to the eviction manager in #25500 does need the connection type.
Of course i could go with your suggestion here and add back the connection type in a later commit for the outbound logic. Let me know if you prefer that.
0@@ -0,0 +1,27 @@
1+// Copyright (c) 2009-2010 Satoshi Nakamoto
1260@@ -1261,6 +1261,7 @@ struct NodeEvictionCandidate
1261 bool prefer_evict;
1262 bool m_is_local;
1263 Network m_network;
1264+ bool m_noban;
git --color-moved
that the move-only changes are indeed move-only.
8@@ -9,6 +9,7 @@
9 #include <chainparams.h>
10 #include <common/bloom.h>
11 #include <compat.h>
12+#include <node/connection_types.h>