aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorMartin Zumsande <mzumsande@gmail.com>2023-12-11 14:37:56 -0500
committerMartin Zumsande <mzumsande@gmail.com>2023-12-27 16:39:32 -0500
commit770c0311ef5e35444efe4fd26f7bb5782624cf2c (patch)
tree41d90ddca13004630d8a3c0724412ba1aa6d13b4 /src/net.h
parentd5e5810bd36f6e899d64a57e9264729b27a9c3f8 (diff)
net: attempt v2 transport for manual connections if we support it
This affects manual connections made either with -connect, or with -addnode provided as a bitcoind config arg (the addnode RPC has an extra option for v2). We don't necessarily know if our peer supports v2, but will reconnect with v1 if they don't. In order to do that, improve the reconnection behavior such that we will reconnect after a sleep of 500ms (which usually should be enough for our peer to send us their version message).
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/net.h b/src/net.h
index 547e032ba6..6b9386e511 100644
--- a/src/net.h
+++ b/src/net.h
@@ -1084,10 +1084,11 @@ public:
vWhitelistedRange = connOptions.vWhitelistedRange;
{
LOCK(m_added_nodes_mutex);
-
+ // 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);
for (const std::string& added_node : connOptions.m_added_nodes) {
- // -addnode cli arg does not currently have a way to signal BIP324 support
- m_added_node_params.push_back({added_node, false});
+ m_added_node_params.push_back({added_node, use_v2transport});
}
}
m_onion_binds = connOptions.onion_binds;