@@ -1707,7 +1707,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
17071707 int nOutboundFullRelay = 0 ;
17081708 int nOutboundBlockRelay = 0 ;
17091709 int outbound_privacy_network_peers = 0 ;
1710- std::set<std::vector<unsigned char >> setConnected; // netgroups of our ipv4/ipv6 outbound peers
1710+ std::set<std::vector<unsigned char >> outbound_ipv46_peer_netgroups;
17111711
17121712 {
17131713 LOCK (m_nodes_mutex);
@@ -1729,7 +1729,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
17291729 case ConnectionType::MANUAL:
17301730 case ConnectionType::OUTBOUND_FULL_RELAY:
17311731 case ConnectionType::BLOCK_RELAY:
1732- CAddress address{pnode->addr };
1732+ const CAddress address{pnode->addr };
17331733 if (address.IsTor () || address.IsI2P () || address.IsCJDNS ()) {
17341734 // Since our addrman-groups for these networks are
17351735 // random, without relation to the route we
@@ -1740,7 +1740,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
17401740 // these networks.
17411741 ++outbound_privacy_network_peers;
17421742 } else {
1743- setConnected .insert (m_netgroupman.GetGroup (address));
1743+ outbound_ipv46_peer_netgroups .insert (m_netgroupman.GetGroup (address));
17441744 }
17451745 } // no default case, so the compiler can warn about missing cases
17461746 }
@@ -1815,7 +1815,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
18151815 m_anchors.pop_back ();
18161816 if (!addr.IsValid () || IsLocal (addr) || !IsReachable (addr) ||
18171817 !HasAllDesirableServiceFlags (addr.nServices ) ||
1818- setConnected .count (m_netgroupman.GetGroup (addr))) continue ;
1818+ outbound_ipv46_peer_netgroups .count (m_netgroupman.GetGroup (addr))) continue ;
18191819 addrConnect = addr;
18201820 LogPrint (BCLog::NET, " Trying to make an anchor connection to %s\n " , addrConnect.ToStringAddrPort ());
18211821 break ;
@@ -1855,8 +1855,8 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
18551855 std::tie (addr, addr_last_try) = addrman.Select ();
18561856 }
18571857
1858- // Require outbound connections, other than feelers, to be to distinct network groups
1859- if (!fFeeler && setConnected .count (m_netgroupman.GetGroup (addr))) {
1858+ // Require outbound IPv4/IPv6 connections, other than feelers, to be to distinct network groups
1859+ if (!fFeeler && outbound_ipv46_peer_netgroups .count (m_netgroupman.GetGroup (addr))) {
18601860 break ;
18611861 }
18621862
@@ -1902,8 +1902,9 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
19021902 // Record addrman failure attempts when node has at least 2 persistent outbound connections to peers with
19031903 // different netgroups in ipv4/ipv6 networks + all peers in Tor/I2P/CJDNS networks.
19041904 // Don't record addrman failure attempts when node is offline. This can be identified since all local
1905- // network connections(if any) belong in the same netgroup and size of setConnected would only be 1.
1906- OpenNetworkConnection (addrConnect, (int )setConnected.size () + outbound_privacy_network_peers >= std::min (nMaxConnections - 1 , 2 ), &grant, nullptr , conn_type);
1905+ // network connections (if any) belong in the same netgroup, and the size of `outbound_ipv46_peer_netgroups` would only be 1.
1906+ const bool count_failures{((int )outbound_ipv46_peer_netgroups.size () + outbound_privacy_network_peers) >= std::min (nMaxConnections - 1 , 2 )};
1907+ OpenNetworkConnection (addrConnect, count_failures, &grant, /* strDest=*/ nullptr , conn_type);
19071908 }
19081909 }
19091910}
0 commit comments