Skip to content

Commit 904fc84

Browse files
committed
[remove] add logging
1 parent 4b6d913 commit 904fc84

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

src/init.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
942942
nLocalServices = ServiceFlags(nLocalServices | NODE_P2P_V2);
943943
if (args.GetBoolArg("-v2onlyclearnet", false)) {
944944
disable_v1conn_clearnet = true;
945+
LogPrintf("### BLANKET V2 ONLY OPTION SET\n");
945946
}
946947
} else if (args.GetBoolArg("-v2onlyclearnet", false)) {
947948
return InitError(_("Cannot set -v2onlyclearnet to true when v2transport is disabled."));

src/net.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,8 @@ void CConnman::DisconnectNodes()
18931893
// Add to reconnection list if appropriate. We don't reconnect right here, because
18941894
// the creation of a connection is a blocking operation (up to several seconds),
18951895
// and we don't want to hold up the socket handler thread for that long.
1896-
if (pnode->m_transport->ShouldReconnectV1() && !DisableV1OnClearnet(pnode->addr.GetNetClass())) {
1896+
std::string str = "### DisableV1OnClearnet() called from DisconnectNodes() with addr= " + pnode->addr.ToStringAddrPort();
1897+
if (pnode->m_transport->ShouldReconnectV1() && !DisableV1OnClearnet(pnode->addr.GetNetClass(), str)) {
18971898
reconnections_to_add.push_back({
18981899
.addr_connect = pnode->addr,
18991900
.grant = std::move(pnode->grantOutbound),
@@ -1903,6 +1904,10 @@ void CConnman::DisconnectNodes()
19031904
LogPrint(BCLog::NET, "retrying with v1 transport protocol for peer=%d\n", pnode->GetId());
19041905
}
19051906

1907+
if (pnode->m_transport->ShouldReconnectV1() && DisableV1OnClearnet(pnode->addr.GetNetClass(), str)) {
1908+
LogPrintf("### 2. DisconnectNodes(): NOT RETRYING WITH V1 FOR %s\n", pnode->addr.ToStringAddrPort());
1909+
}
1910+
19061911
// release outbound grant (if any)
19071912
pnode->grantOutbound.Release();
19081913

@@ -2436,8 +2441,9 @@ bool CConnman::MultipleManualOrFullOutboundConns(Network net) const
24362441
return m_network_conn_counts[net] > 1;
24372442
}
24382443

2439-
bool CConnman::DisableV1OnClearnet(Network net) const
2444+
bool CConnman::DisableV1OnClearnet(Network net, std::string str) const
24402445
{
2446+
LogPrintf("%s\n", str);
24412447
return disable_v1conn_clearnet && (net == NET_IPV4 || net == NET_IPV6);
24422448
}
24432449

@@ -2742,7 +2748,9 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
27422748
}
27432749

27442750
bool use_v2transport(addr.nServices & GetLocalServices() & NODE_P2P_V2);
2745-
if (DisableV1OnClearnet(addr.GetNetClass()) && !use_v2transport) {
2751+
std::string str = "### DisableV1OnClearnet() called from ThreadOpenConnections() with addr= " + addr.ToStringAddrPort();
2752+
if (DisableV1OnClearnet(addr.GetNetClass(), str) && !use_v2transport) {
2753+
LogPrintf("### 3. ThreadOpenConnections(): %s selected from addrman for making BLOCK + FEELER + OUTBOUND is NOT V2 - WE LOOP AGAIN FOR V2\n", addr.ToStringAddrPort());
27462754
continue;
27472755
}
27482756

@@ -2929,15 +2937,20 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
29292937
return;
29302938

29312939
enum Network netclass;
2940+
std::string str;
2941+
std::string host;
29322942
if (pszDest) {
2933-
std::string host;
2943+
LogPrintf("pszDest = %s\n", std::string(pszDest));
29342944
uint16_t port;
29352945
SplitHostPort(std::string(pszDest), port, host);
29362946
netclass = LookupHost(host, false).value().GetNetClass();
2947+
str = "### DisableV1OnClearnet() called from OpenNetworkConnection() with addr= " + host;
29372948
} else {
29382949
netclass = addrConnect.GetNetClass();
2950+
str = "### DisableV1OnClearnet() called from OpenNetworkConnection() with addr= " + addrConnect.ToStringAddrPort();
29392951
}
2940-
if (DisableV1OnClearnet(netclass) && !use_v2transport) {
2952+
if (DisableV1OnClearnet(netclass, str) && !use_v2transport) {
2953+
LogPrintf("### 4. OpenNetworkConnection(): %s does NOT look like a potential V2 PEER\n", pszDest ? host : addrConnect.ToStringAddrPort());
29412954
return;
29422955
}
29432956

src/net.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ class CConnman
12501250
bool MultipleManualOrFullOutboundConns(Network net) const EXCLUSIVE_LOCKS_REQUIRED(m_nodes_mutex);
12511251

12521252
/* Disables v1 connections on IPV4/IPV6 network. */
1253-
bool DisableV1OnClearnet(Network net) const;
1253+
bool DisableV1OnClearnet(Network net, std::string str) const;
12541254

12551255
private:
12561256
struct ListenSocket {

src/net_processing.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -3735,7 +3735,10 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
37353735
}
37363736

37373737
const bool is_v1transport = pfrom.m_transport->GetInfo().transport_type == TransportProtocolType::V1;
3738-
if (pfrom.IsInboundConn() && is_v1transport && m_connman.DisableV1OnClearnet(pfrom.ConnectedThroughNetwork())){
3738+
std::string str = "DisableV1OnClearnet() called from ProcessMessage() with addr= " + pfrom.addr.ToStringAddrPort();
3739+
if (pfrom.IsInboundConn() && is_v1transport && m_connman.DisableV1OnClearnet(pfrom.ConnectedThroughNetwork(), str)){
3740+
LogPrintf("### 1. ProcessMessage(): INBOUND CONNECTION from %s is NOT V2 PEER\n", pfrom.addr.ToStringAddrPort());
3741+
LogPrintf("### nServices & NODE_P2P_V2 = %d\n", nServices & NODE_P2P_V2);
37393742
pfrom.fDisconnect = true;
37403743
return;
37413744
}

0 commit comments

Comments
 (0)