MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / MaybePickPreferredNetwork

Method MaybePickPreferredNetwork

src/net.cpp:2551–2567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2549}
2550
2551bool CConnman::MaybePickPreferredNetwork(std::optional<Network>& network)
2552{
2553 AssertLockNotHeld(m_nodes_mutex);
2554
2555 std::array<Network, 5> nets{NET_IPV4, NET_IPV6, NET_ONION, NET_I2P, NET_CJDNS};
2556 std::shuffle(nets.begin(), nets.end(), FastRandomContext());
2557
2558 LOCK(m_nodes_mutex);
2559 for (const auto net : nets) {
2560 if (g_reachable_nets.Contains(net) && m_network_conn_counts[net] == 0 && addrman.get().Size(net) != 0) {
2561 network = net;
2562 return true;
2563 }
2564 }
2565
2566 return false;
2567}
2568
2569void CConnman::ThreadOpenConnections(const std::vector<std::string> connect, std::span<const std::string> seed_nodes)
2570{

Callers

nothing calls this directly

Calls 6

FastRandomContextClass · 0.70
beginMethod · 0.45
endMethod · 0.45
ContainsMethod · 0.45
SizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected