From 4ee7aec47ebf6b59b4d930e6e4025e91352c05b4 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Thu, 10 Jun 2021 11:44:55 +0200 Subject: [PATCH] p2p: add m_network to NodeEvictionCandidate struct --- src/net.cpp | 2 +- src/net.h | 1 + src/test/fuzz/node_eviction.cpp | 1 + src/test/net_peer_eviction_tests.cpp | 3 +++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 16c66d24709..71e7754ad4e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1023,7 +1023,7 @@ bool CConnman::AttemptToEvictConnection() HasAllDesirableServiceFlags(node->nServices), peer_relay_txes, peer_filter_not_null, node->nKeyedNetGroup, node->m_prefer_evict, node->addr.IsLocal(), - node->m_inbound_onion}; + node->m_inbound_onion, node->ConnectedThroughNetwork()}; vEvictionCandidates.push_back(candidate); } } diff --git a/src/net.h b/src/net.h index b43916c55ec..a0708c338b0 100644 --- a/src/net.h +++ b/src/net.h @@ -1210,6 +1210,7 @@ struct NodeEvictionCandidate bool prefer_evict; bool m_is_local; bool m_is_onion; + Network m_network; }; /** diff --git a/src/test/fuzz/node_eviction.cpp b/src/test/fuzz/node_eviction.cpp index 70ffc6bf37f..9f02b5271b6 100644 --- a/src/test/fuzz/node_eviction.cpp +++ b/src/test/fuzz/node_eviction.cpp @@ -32,6 +32,7 @@ FUZZ_TARGET(node_eviction) /* prefer_evict */ fuzzed_data_provider.ConsumeBool(), /* m_is_local */ fuzzed_data_provider.ConsumeBool(), /* m_is_onion */ fuzzed_data_provider.ConsumeBool(), + /* m_network */ fuzzed_data_provider.PickValueInArray(ALL_NETWORKS), }); } // Make a copy since eviction_candidates may be in some valid but otherwise diff --git a/src/test/net_peer_eviction_tests.cpp b/src/test/net_peer_eviction_tests.cpp index 3b981cf69c5..7e74b6f6a32 100644 --- a/src/test/net_peer_eviction_tests.cpp +++ b/src/test/net_peer_eviction_tests.cpp @@ -2,7 +2,9 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include #include +#include #include #include @@ -32,6 +34,7 @@ std::vector GetRandomNodeEvictionCandidates(const int n_c /* prefer_evict */ random_context.randbool(), /* m_is_local */ random_context.randbool(), /* m_is_onion */ random_context.randbool(), + /* m_network */ ALL_NETWORKS[random_context.randrange(ALL_NETWORKS.size())], }); } return candidates;