From 745ad941dedaa0f4e2a5fdda58a3bf683d672196 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Tue, 6 Jan 2026 02:00:15 +0100 Subject: [PATCH] p2p: remove m_starting_height field from node state (only show once in debug log) --- src/net.h | 1 - src/net_processing.cpp | 18 +++++------------- src/net_processing.h | 1 - 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/net.h b/src/net.h index d4de261e7b3..d923e7b28fe 100644 --- a/src/net.h +++ b/src/net.h @@ -205,7 +205,6 @@ public: bool m_bip152_highbandwidth_to; // Peer requested high bandwidth connection bool m_bip152_highbandwidth_from; - int m_starting_height; uint64_t nSendBytes; mapMsgTypeSize mapSendBytesPerMsgType; uint64_t nRecvBytes; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index a94246581d3..e36d147c324 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -272,10 +272,6 @@ struct Peer { /** Set to true once initial VERSION message was sent (only relevant for outbound peers). */ bool m_outbound_version_message_sent GUARDED_BY(NetEventsInterface::g_msgproc_mutex){false}; - /** This peer's reported block height when we connected */ - // TODO: remove in v32.0, only show reported height once in "receive version message: ..." debug log - std::atomic m_starting_height{-1}; - /** The pong reply we're expecting, or 0 if no pong expected. */ std::atomic m_ping_nonce_sent{0}; /** When the last ping was sent, or 0 if no ping was ever sent */ @@ -1804,7 +1800,6 @@ bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) c PeerRef peer = GetPeerRef(nodeid); if (peer == nullptr) return false; stats.their_services = peer->m_their_services; - stats.m_starting_height = peer->m_starting_height; // It is common for nodes with good ping times to suddenly become lagged, // due to a new block arriving or other large transfer. // Merely reporting pingtime might fool the caller into thinking the node was still responsive, @@ -3106,8 +3101,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer, if (nCount == m_opts.max_headers_result && !have_headers_sync) { // Headers message had its maximum size; the peer may have more headers. if (MaybeSendGetHeaders(pfrom, GetLocator(pindexLast), peer)) { - LogDebug(BCLog::NET, "more getheaders (%d) to end to peer=%d (startheight:%d)\n", - pindexLast->nHeight, pfrom.GetId(), peer.m_starting_height); + LogDebug(BCLog::NET, "more getheaders (%d) to end to peer=%d", pindexLast->nHeight, pfrom.GetId()); } } @@ -3675,7 +3669,6 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string LOCK(pfrom.m_subver_mutex); pfrom.cleanSubVer = cleanSubVer; } - peer.m_starting_height = starting_height; // Only initialize the Peer::TxRelay m_relay_txs data structure if: // - this isn't an outbound block-relay-only connection, and @@ -3697,7 +3690,7 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string const auto mapped_as{m_connman.GetMappedAS(pfrom.addr)}; LogDebug(BCLog::NET, "receive version message: %s: version %d, blocks=%d, us=%s, txrelay=%d, %s%s", cleanSubVer.empty() ? "" : cleanSubVer, pfrom.nVersion, - peer.m_starting_height, addrMe.ToStringAddrPort(), fRelay, pfrom.LogPeer(), + starting_height, addrMe.ToStringAddrPort(), fRelay, pfrom.LogPeer(), (mapped_as ? strprintf(", mapped_as=%d", mapped_as) : "")); if (pfrom.IsPrivateBroadcastConn()) { @@ -3825,11 +3818,10 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string auto new_peer_msg = [&]() { const auto mapped_as{m_connman.GetMappedAS(pfrom.addr)}; - return strprintf("New %s peer connected: transport: %s, version: %d, blocks=%d, %s%s", + return strprintf("New %s peer connected: transport: %s, version: %d, %s%s", pfrom.ConnectionTypeAsString(), TransportTypeAsString(pfrom.m_transport->GetInfo().transport_type), - pfrom.nVersion.load(), peer.m_starting_height, - pfrom.LogPeer(), + pfrom.nVersion.load(), pfrom.LogPeer(), (mapped_as ? strprintf(", mapped_as=%d", mapped_as) : "")); }; @@ -5807,7 +5799,7 @@ bool PeerManagerImpl::SendMessages(CNode& node) if (pindexStart->pprev) pindexStart = pindexStart->pprev; if (MaybeSendGetHeaders(node, GetLocator(pindexStart), peer)) { - LogDebug(BCLog::NET, "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, node.GetId(), peer.m_starting_height); + LogDebug(BCLog::NET, "initial getheaders (%d) to peer=%d", pindexStart->nHeight, node.GetId()); state.fSyncStarted = true; peer.m_headers_sync_timeout = current_time + HEADERS_DOWNLOAD_TIMEOUT_BASE + diff --git a/src/net_processing.h b/src/net_processing.h index 36ae021f679..6339852327b 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -53,7 +53,6 @@ static const unsigned int MAX_HEADERS_RESULTS = 2000; struct CNodeStateStats { int nSyncHeight = -1; int nCommonHeight = -1; - int m_starting_height = -1; std::chrono::microseconds m_ping_wait; std::vector vHeightInFlight; bool m_relay_txs;