From b866e9f14c5aa7090c21b02302d20e7a615a3ed8 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 30 Oct 2013 14:11:11 -0500 Subject: [PATCH] Improve RPC server log of rejected transactions. Rather than showing all errors from ProcessTransaction as an error, check if the error is a TxRuleError meaning the transaction was rejected as opposed to something actually going wrong and log it accordingly. --- rpcserver.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rpcserver.go b/rpcserver.go index e02c81c3..dcb143c2 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -606,7 +606,15 @@ func handleSendRawTransaction(s *rpcServer, cmd btcjson.Cmd, walletNotification tx := btcutil.NewTx(msgtx) err = s.server.txMemPool.ProcessTransaction(tx) if err != nil { - log.Errorf("RPCS: Failed to process transaction: %v", 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.Debugf("RPCS: Rejected transaction %v: %v", txHash, err) + } else { + log.Errorf("RPCS: Failed to process transaction %v: %v", txHash, err) + } err = btcjson.Error{ Code: btcjson.ErrDeserialization.Code, Message: "Failed to process transaction",