p2p: Protect extra full outbound peers by network

If a peer is the only one of its network, protect it from eviction.
This improves the diversity of outbound connections with respect to
reachable networks.

Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
This commit is contained in:
Martin Zumsande
2023-02-07 16:03:32 -05:00
committed by Amiti Uttarwar
parent 654d9bc276
commit 034f61f83b
3 changed files with 17 additions and 1 deletions

View File

@@ -1607,6 +1607,12 @@ std::unordered_set<Network> CConnman::GetReachableEmptyNetworks() const
return networks;
}
bool CConnman::MultipleManualOrFullOutboundConns(Network net) const
{
AssertLockHeld(m_nodes_mutex);
return m_network_conn_counts[net] > 1;
}
void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
{
AssertLockNotHeld(m_unused_i2p_sessions_mutex);