net: attempt v2 transport for addrfetch connections if we support it

This commit is contained in:
Martin Zumsande 2023-12-11 16:05:29 -05:00
parent 770c0311ef
commit 9eed22e870

View file

@ -2322,10 +2322,13 @@ void CConnman::ProcessAddrFetch()
strDest = m_addr_fetches.front();
m_addr_fetches.pop_front();
}
// Attempt v2 connection if we support v2 - we'll reconnect with v1 if our
// peer doesn't support it or immediately disconnects us for another reason.
const bool use_v2transport(GetLocalServices() & NODE_P2P_V2);
CAddress addr;
CSemaphoreGrant grant(*semOutbound, /*fTry=*/true);
if (grant) {
OpenNetworkConnection(addr, false, std::move(grant), strDest.c_str(), ConnectionType::ADDR_FETCH, /*use_v2transport=*/false);
OpenNetworkConnection(addr, false, std::move(grant), strDest.c_str(), ConnectionType::ADDR_FETCH, use_v2transport);
}
}