Skip to content

Commit 2c3a90f

Browse files
committed
log: on new valid header
1 parent e5ce857 commit 2c3a90f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/validation.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3832,6 +3832,23 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
38323832
if (ppindex)
38333833
*ppindex = pindex;
38343834

3835+
// Since this is the earliest point at which we have determined that a
3836+
// header is both new and valid, log here.
3837+
//
3838+
// These messages are valuable for detecting potential selfish mining behavior;
3839+
// if multiple displacing headers are seen near simultaneously across many
3840+
// nodes in the network, this might be an indication of selfish mining. Having
3841+
// this log by default when not in IBD ensures broad availability of this data
3842+
// in case investigation is merited.
3843+
const auto msg = strprintf(
3844+
"Saw new header hash=%s height=%d", hash.ToString(), pindex->nHeight);
3845+
3846+
if (ActiveChainstate().IsInitialBlockDownload()) {
3847+
LogPrintLevel(BCLog::VALIDATION, BCLog::Level::Debug, "%s\n", msg);
3848+
} else {
3849+
LogPrintf("%s\n", msg);
3850+
}
3851+
38353852
return true;
38363853
}
38373854

0 commit comments

Comments
 (0)