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.
This commit is contained in:
Dave Collins 2013-10-30 14:11:11 -05:00
parent e76fada2d2
commit b866e9f14c

View file

@ -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",