mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-17 11:00:44 +01:00
Merge bitcoin/bitcoin#27278: Log new headers
2c3a90f663log: on new valid header (James O'Beirne)e5ce857634log: net: new header over cmpctblock (James O'Beirne) Pull request description: Alternate to #27276. Devs were [suprised to realize](https://twitter.com/jamesob/status/1637237917201383425) last night that we don't have definitive logging for when a given header was first received. This logs to the main stream when new headers are received outside of IBD, as well as when headers come in over cmpctblocks. The rationale of not hiding these under log categories is that they may be useful to have widely available when debugging strange network activity, and the marginal volume is modest. ACKs for top commit: dergoegge: Code review ACK2c3a90f663achow101: ACK2c3a90f663Sjors: tACK2c3a90f663josibake: ACK2c3a90f663Tree-SHA512: 49fdcbe07799c8adc24143d7e5054a0c93fef120d2e9d5fddbd3b119550d895e2985be6ac10dd1825ea23a6fa5479c1b76d5518c136fbd983fa76c0d39dc354f
This commit is contained in:
@@ -3845,6 +3845,23 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
|
||||
if (ppindex)
|
||||
*ppindex = pindex;
|
||||
|
||||
// Since this is the earliest point at which we have determined that a
|
||||
// header is both new and valid, log here.
|
||||
//
|
||||
// These messages are valuable for detecting potential selfish mining behavior;
|
||||
// if multiple displacing headers are seen near simultaneously across many
|
||||
// nodes in the network, this might be an indication of selfish mining. Having
|
||||
// this log by default when not in IBD ensures broad availability of this data
|
||||
// in case investigation is merited.
|
||||
const auto msg = strprintf(
|
||||
"Saw new header hash=%s height=%d", hash.ToString(), pindex->nHeight);
|
||||
|
||||
if (ActiveChainstate().IsInitialBlockDownload()) {
|
||||
LogPrintLevel(BCLog::VALIDATION, BCLog::Level::Debug, "%s\n", msg);
|
||||
} else {
|
||||
LogPrintf("%s\n", msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user