Merge bitcoin/bitcoin#25500: refactor: Move inbound eviction logic to its own translation unit

0101d2bc3c [net] Move eviction logic to its own file (dergoegge)
c741d748d4 [net] Move ConnectionType to its own file (Cory Fields)
a3c2707039 [net] Add connection type to NodeEvictionCandidate (dergoegge)
42aa5d5b62 [net] Add NoBan status to NodeEvictionCandidate (dergoegge)

Pull request description:

  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.

ACKs for top commit:
  jnewbery:
    utACK 0101d2bc3c
  theuni:
    utACK 0101d2bc3c. I quickly verified with `git --color-moved` that the move-only changes are indeed move-only.

Tree-SHA512: e0c345a698030e049cb22fe281b44503c04403c5be5a3750ca14bfcc603a162ac6bac9a39552472feb57c460102b7ca91430b8ad6268f2efccc49b5e8959331b
This commit is contained in:
fanquake
2022-07-07 17:52:44 +01:00
10 changed files with 431 additions and 350 deletions

View File

@@ -32,6 +32,8 @@ FUZZ_TARGET(node_eviction)
/*prefer_evict=*/fuzzed_data_provider.ConsumeBool(),
/*m_is_local=*/fuzzed_data_provider.ConsumeBool(),
/*m_network=*/fuzzed_data_provider.PickValueInArray(ALL_NETWORKS),
/*m_noban=*/fuzzed_data_provider.ConsumeBool(),
/*m_conn_type=*/fuzzed_data_provider.PickValueInArray(ALL_CONNECTION_TYPES),
});
}
// Make a copy since eviction_candidates may be in some valid but otherwise

View File

@@ -5,6 +5,7 @@
#include <test/util/net.h>
#include <chainparams.h>
#include <node/eviction.h>
#include <net.h>
#include <span.h>
@@ -58,6 +59,8 @@ std::vector<NodeEvictionCandidate> GetRandomNodeEvictionCandidates(int n_candida
/*prefer_evict=*/random_context.randbool(),
/*m_is_local=*/random_context.randbool(),
/*m_network=*/ALL_NETWORKS[random_context.randrange(ALL_NETWORKS.size())],
/*m_noban=*/false,
/*m_conn_type=*/ConnectionType::INBOUND,
});
}
return candidates;

View File

@@ -6,6 +6,7 @@
#define BITCOIN_TEST_UTIL_NET_H
#include <compat.h>
#include <node/eviction.h>
#include <netaddress.h>
#include <net.h>
#include <util/sock.h>