Improve logging of rejected blocks.

Rather than showing all errors from ProcessBlock as a failure, check if
the error is a RuleError meaning the block was rejected as opposed to
something actually going wrong and log it accordingly.
This commit is contained in:
Dave Collins 2013-10-04 13:13:16 -05:00
parent c3a17de326
commit 78b555fcf9

View file

@ -277,7 +277,16 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) {
if err != nil {
delete(b.blockPeer, *blockSha)
log.Warnf("[BMGR] Failed to process block %v: %v", blockSha, err)
// When the error is a rule error, it means the block was simply
// rejected as opposed to something actually going wrong, so log
// it as such. Otherwise, something really did go wrong, so log
// it as an actual error.
if _, ok := err.(btcchain.RuleError); ok {
log.Warnf("[BMGR] Rejected block %v: %v", blockSha, err)
} else {
log.Errorf("[BMGR] Failed to process block %v: %v", blockSha, err)
}
return
}