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

Method PickNetwork

src/net.cpp:3122–3153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3120}
3121
3122std::optional<Network> CConnman::PrivateBroadcast::PickNetwork(std::optional<Proxy>& proxy) const
3123{
3124 prevector<4, Network> nets;
3125 std::optional<Proxy> clearnet_proxy;
3126 proxy.reset();
3127 if (g_reachable_nets.Contains(NET_ONION)) {
3128 nets.push_back(NET_ONION);
3129
3130 clearnet_proxy = ProxyForIPv4or6();
3131 if (clearnet_proxy.has_value()) {
3132 if (g_reachable_nets.Contains(NET_IPV4)) {
3133 nets.push_back(NET_IPV4);
3134 }
3135 if (g_reachable_nets.Contains(NET_IPV6)) {
3136 nets.push_back(NET_IPV6);
3137 }
3138 }
3139 }
3140 if (g_reachable_nets.Contains(NET_I2P)) {
3141 nets.push_back(NET_I2P);
3142 }
3143
3144 if (nets.empty()) {
3145 return std::nullopt;
3146 }
3147
3148 const Network net{nets[FastRandomContext{}.randrange(nets.size())]};
3149 if (net == NET_IPV4 || net == NET_IPV6) {
3150 proxy = clearnet_proxy;
3151 }
3152 return net;
3153}
3154
3155size_t CConnman::PrivateBroadcast::NumToOpen() const
3156{

Callers 1

Calls 7

randrangeMethod · 0.80
resetMethod · 0.45
ContainsMethod · 0.45
push_backMethod · 0.45
has_valueMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected