mirror of https://github.com/bitcoin/bitcoin.git
p2p: Add warning message when receiving headers for blocks cached as invalid
Currently, if database corruption leads to a block being marked as invalid incorrectly, we can get stuck in an infinite headerssync loop with no indication what went wrong or how to fix it. With the added log message, users will receive an explicit warning after each failed headerssync attempt with an outbound peer.
This commit is contained in:
parent
a33bd767a3
commit
419ff388b9
|
@ -2956,6 +2956,12 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
|
|||
state, &pindexLast)};
|
||||
if (!processed) {
|
||||
if (state.IsInvalid()) {
|
||||
if (!pfrom.IsInboundConn() && state.GetResult() == BlockValidationResult::BLOCK_CACHED_INVALID) {
|
||||
LogWarning("Header received from peer=%i was previously marked as invalid. "
|
||||
"If this happens with all peers, database corruption is likely and "
|
||||
"-reindex may be necessary to recover.",
|
||||
pfrom.GetId());
|
||||
}
|
||||
MaybePunishNodeForBlock(pfrom.GetId(), state, via_compact_block, "invalid header received");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue