From 78b555fcf9e6fa1869283a2ee26804518d09d8ae Mon Sep 17 00:00:00 2001
From: Dave Collins <davec@conformal.com>
Date: Fri, 4 Oct 2013 13:13:16 -0500
Subject: [PATCH] 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.
---
 blockmanager.go | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/blockmanager.go b/blockmanager.go
index 7df808b3..5c53a885 100644
--- a/blockmanager.go
+++ b/blockmanager.go
@@ -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
 	}