@@ -1793,6 +1793,13 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
1793
1793
// detected, so use it whenever we signal NODE_P2P_V2.
1794
1794
const bool use_v2transport (nLocalServices & NODE_P2P_V2);
1795
1795
1796
+ if (g_v2_only && !use_v2transport) {
1797
+ // TODO: do we really need to log? do we log connection was accepted?
1798
+ LogPrint (BCLog::NET, " ### 1. NOT V2 PEER - INBOUND CONNECTION\n " );
1799
+ LogPrint (BCLog::NET, " connection from %s dropped (v1 disabled)\n " , addr.ToStringAddrPort ());
1800
+ return ;
1801
+ }
1802
+
1796
1803
CNode* pnode = new CNode (id,
1797
1804
std::move (sock),
1798
1805
addr,
@@ -1893,7 +1900,7 @@ void CConnman::DisconnectNodes()
1893
1900
// Add to reconnection list if appropriate. We don't reconnect right here, because
1894
1901
// the creation of a connection is a blocking operation (up to several seconds),
1895
1902
// and we don't want to hold up the socket handler thread for that long.
1896
- if (pnode->m_transport ->ShouldReconnectV1 ()) {
1903
+ if (!g_v2_only && pnode->m_transport ->ShouldReconnectV1 ()) {
1897
1904
reconnections_to_add.push_back ({
1898
1905
.addr_connect = pnode->addr ,
1899
1906
.grant = std::move (pnode->grantOutbound ),
@@ -2346,6 +2353,13 @@ void CConnman::ProcessAddrFetch()
2346
2353
// Attempt v2 connection if we support v2 - we'll reconnect with v1 if our
2347
2354
// peer doesn't support it or immediately disconnects us for another reason.
2348
2355
const bool use_v2transport (GetLocalServices () & NODE_P2P_V2);
2356
+ if (g_v2_only && !use_v2transport) {
2357
+ // TODO: better if this can be handled in OpenNetworkConnection() itself
2358
+ // because this is at a loss of addrfetch connection
2359
+ // TODO: check how connections are made only if a specific service flag is advertised
2360
+ LogPrint (BCLog::NET, " ### 2. NOT V2 PEER FOR ADDR_FETCH\n " );
2361
+ return ;
2362
+ }
2349
2363
CAddress addr;
2350
2364
CSemaphoreGrant grant (*semOutbound, /* fTry=*/ true );
2351
2365
if (grant) {
@@ -2463,6 +2477,11 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
2463
2477
// Attempt v2 connection if we support v2 - we'll reconnect with v1 if our
2464
2478
// peer doesn't support it or immediately disconnects us for another reason.
2465
2479
const bool use_v2transport (GetLocalServices () & NODE_P2P_V2);
2480
+ if (g_v2_only && !use_v2transport) {
2481
+ // TODO: IMP: does this break out of the next for loop too?
2482
+ LogPrint (BCLog::NET, " ### 3. NOT V2 PEER - BEFORE MANUAL (INSIDE OPENCON)\n " );
2483
+ return ;
2484
+ }
2466
2485
for (int64_t nLoop = 0 ;; nLoop++)
2467
2486
{
2468
2487
for (const std::string& strAddr : connect)
@@ -2766,6 +2785,11 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
2766
2785
continue ;
2767
2786
}
2768
2787
2788
+ bool use_v2transport (addr.nServices & GetLocalServices () & NODE_P2P_V2);
2789
+ if (g_v2_only && !use_v2transport) {
2790
+ LogPrint (BCLog::NET, " ### 4.0 NOT V2 PEER (IN OPENCON) - WE TRY AGAIN FOR V2\n " );
2791
+ continue ;
2792
+ }
2769
2793
addrConnect = addr;
2770
2794
break ;
2771
2795
}
@@ -2883,6 +2907,7 @@ void CConnman::ThreadOpenAddedConnections()
2883
2907
}
2884
2908
tried = true ;
2885
2909
CAddress addr (CService (), NODE_NONE);
2910
+ // TODO
2886
2911
OpenNetworkConnection (addr, false , std::move (grant), info.m_params .m_added_node .c_str (), ConnectionType::MANUAL, info.m_params .m_use_v2transport );
2887
2912
if (!interruptNet.sleep_for (std::chrono::milliseconds (500 ))) return ;
2888
2913
grant = CSemaphoreGrant (*semAddnode, /* fTry=*/ true );
@@ -2916,7 +2941,12 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
2916
2941
return ;
2917
2942
}
2918
2943
} else if (FindNode (std::string (pszDest)))
2944
+ return ; // todo: how is it possible to hit this path
2945
+
2946
+ if (g_v2_only && !use_v2transport) {
2947
+ LogPrint (BCLog::NET, " ### 5. NOT V2 PEER (IN OPENNETWORKCONN())\n " );
2919
2948
return ;
2949
+ }
2920
2950
2921
2951
CNode* pnode = ConnectNode (addrConnect, pszDest, fCountFailure , conn_type, use_v2transport);
2922
2952
0 commit comments