From 223d146a10fa0c61349deadbaf70df64745990bd Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 4 Oct 2013 13:33:54 -0500 Subject: [PATCH] Improve logging of rejected transactions. Rather than showing all errors from ProcessTransaction as a failure, check if the error is a TxRuleError meaning the transaction was rejected as opposed to something actually going wrong and log it accordingly. --- peer.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/peer.go b/peer.go index 7bc1957b..73cb4c43 100644 --- a/peer.go +++ b/peer.go @@ -417,7 +417,15 @@ func (p *peer) handleTxMsg(msg *btcwire.MsgTx) { // Process the transaction. err = p.server.txMemPool.ProcessTransaction(msg) if err != nil { - log.Errorf("Failed to process transaction %v: %v", hash, err) + // When the error is a rule error, it means the transaction 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.(TxRuleError); ok { + log.Warnf("Rejected transaction %v: %v", hash, err) + } else { + log.Errorf("Failed to process transaction %v: %v", hash, err) + } return } }