Skip to content

Commit bad7c91

Browse files
committed
Log which peer sent us a header
This also supports -logips.
1 parent 9d3e39c commit bad7c91

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/net_processing.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ class PeerManagerImpl final : public PeerManager
10721072
void AddAddressKnown(Peer& peer, const CAddress& addr) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
10731073
void PushAddress(Peer& peer, const CAddress& addr) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
10741074

1075-
void LogBlockHeader(const CBlockIndex& index);
1075+
void LogBlockHeader(const CBlockIndex& index, const CNode& peer);
10761076
};
10771077

10781078
const CNodeState* PeerManagerImpl::State(NodeId pnode) const
@@ -2984,7 +2984,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
29842984
assert(pindexLast);
29852985

29862986
if (processed && received_new_header) {
2987-
LogBlockHeader(*pindexLast);
2987+
LogBlockHeader(*pindexLast, pfrom);
29882988
}
29892989

29902990
// Consider fetching more headers if we are not using our headers-sync mechanism.
@@ -3414,7 +3414,7 @@ void PeerManagerImpl::ProcessCompactBlockTxns(CNode& pfrom, Peer& peer, const Bl
34143414
return;
34153415
}
34163416

3417-
void PeerManagerImpl::LogBlockHeader(const CBlockIndex& index) {
3417+
void PeerManagerImpl::LogBlockHeader(const CBlockIndex& index, const CNode& peer) {
34183418
// To prevent log spam, this function should only be called after it was determined that a
34193419
// header is both new and valid.
34203420
//
@@ -3426,9 +3426,11 @@ void PeerManagerImpl::LogBlockHeader(const CBlockIndex& index) {
34263426
// Having this log by default when not in IBD ensures broad availability of
34273427
// this data in case investigation is merited.
34283428
const auto msg = strprintf(
3429-
"Saw new header hash=%s height=%d",
3429+
"Saw new header hash=%s height=%d peer=%d%s",
34303430
index.GetBlockHash().ToString(),
3431-
index.nHeight
3431+
index.nHeight,
3432+
peer.GetId(),
3433+
peer.LogIP(fLogIPs)
34323434
);
34333435
if (m_chainman.IsInitialBlockDownload()) {
34343436
LogDebug(BCLog::VALIDATION, "%s", msg);

0 commit comments

Comments
 (0)