Skip to content

Commit 8b59231

Browse files
committed
Merge bitcoin/bitcoin#27761: p2p: Log addresses of stalling peers
fb02a3c p2p: Log addresses of stalling peers (Martin Zumsande) Pull request description: This was suggested in #27705 by ArmchairCryptologist. It allows node operators that have the `-logips` option enabled to better identify potentially misbehaving peers and maybe ban them. This is especially helpful in case of inbound peers for which (dis)connections aren't logged per default, so it's impossible to use the debug log to connect their `nodeId` to an address unless the very noisy `net` debugging is enabled. In case of outbound peers for which the address is potentially logged when establishing the connection, this just adds some convenience. ACKs for top commit: stratospher: tACK fb02a3c. jamesob: github ACK bitcoin/bitcoin@fb02a3c 0xB10C: Untested ACK fb02a3c instagibbs: utACK fb02a3c Tree-SHA512: 2080f794c715bd36143405828b4b0e1be859095caf8f8a0c20dd2a4b64d192d78fee0fa350a2bb7c39848718332c4dd4d8edb2cc8d22095b65afe710591f7ccb
2 parents 7794d9d + fb02a3c commit 8b59231

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5831,7 +5831,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
58315831
// Stalling only triggers when the block download window cannot move. During normal steady state,
58325832
// the download window should be much larger than the to-be-downloaded set of blocks, so disconnection
58335833
// should only happen during initial block download.
5834-
LogPrintf("Peer=%d is stalling block download, disconnecting\n", pto->GetId());
5834+
LogPrintf("Peer=%d%s is stalling block download, disconnecting\n", pto->GetId(), fLogIPs ? strprintf(" peeraddr=%s", pto->addr.ToStringAddrPort()) : "");
58355835
pto->fDisconnect = true;
58365836
// Increase timeout for the next peer so that we don't disconnect multiple peers if our own
58375837
// bandwidth is insufficient.
@@ -5850,7 +5850,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
58505850
QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
58515851
int nOtherPeersWithValidatedDownloads = m_peers_downloading_from - 1;
58525852
if (current_time > state.m_downloading_since + std::chrono::seconds{consensusParams.nPowTargetSpacing} * (BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads)) {
5853-
LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", queuedBlock.pindex->GetBlockHash().ToString(), pto->GetId());
5853+
LogPrintf("Timeout downloading block %s from peer=%d%s, disconnecting\n", queuedBlock.pindex->GetBlockHash().ToString(), pto->GetId(), fLogIPs ? strprintf(" peeraddr=%s", pto->addr.ToStringAddrPort()) : "");
58545854
pto->fDisconnect = true;
58555855
return true;
58565856
}
@@ -5866,11 +5866,11 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
58665866
// disconnect our sync peer for stalling; we have bigger
58675867
// problems if we can't get any outbound peers.
58685868
if (!pto->HasPermission(NetPermissionFlags::NoBan)) {
5869-
LogPrintf("Timeout downloading headers from peer=%d, disconnecting\n", pto->GetId());
5869+
LogPrintf("Timeout downloading headers from peer=%d%s, disconnecting\n", pto->GetId(), fLogIPs ? strprintf(" peeraddr=%s", pto->addr.ToStringAddrPort()) : "");
58705870
pto->fDisconnect = true;
58715871
return true;
58725872
} else {
5873-
LogPrintf("Timeout downloading headers from noban peer=%d, not disconnecting\n", pto->GetId());
5873+
LogPrintf("Timeout downloading headers from noban peer=%d%s, not disconnecting\n", pto->GetId(), fLogIPs ? strprintf(" peeraddr=%s", pto->addr.ToStringAddrPort()) : "");
58745874
// Reset the headers sync state so that we have a
58755875
// chance to try downloading from a different peer.
58765876
// Note: this will also result in at least one more

0 commit comments

Comments
 (0)