From 2791b22d8378df4d9045edc5127e4f68d1a31ba9 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Wed, 8 Apr 2020 14:22:12 -0500 Subject: [PATCH] core, eth: Only show rejections if err is not nil --- core/tx_pool.go | 10 ++++++---- eth/filters/dropped_tx_subscription.go | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 322a3e07ec..8e036fe9e1 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -853,10 +853,12 @@ func (pool *TxPool) addTxs(txs []*types.Transaction, local, sync bool) []error { for errs[nilSlot] != nil { nilSlot++ } - pool.rejectTxFeed.Send(RejectedTxEvent{ - Tx: txs[nilSlot], - Reason: err, - }) + if err != nil { + pool.rejectTxFeed.Send(RejectedTxEvent{ + Tx: txs[nilSlot], + Reason: err, + }) + } errs[nilSlot] = err } // Reorg the pool internals if needed and return diff --git a/eth/filters/dropped_tx_subscription.go b/eth/filters/dropped_tx_subscription.go index 5e95c0c8e9..6116def83d 100644 --- a/eth/filters/dropped_tx_subscription.go +++ b/eth/filters/dropped_tx_subscription.go @@ -15,7 +15,7 @@ type dropNotification struct { } type rejectNotification struct { - Tx *types.Transaction + Tx *types.Transaction `json:"tx"` Reason string `json:"reason"` } @@ -67,7 +67,11 @@ func (api *PublicFilterAPI) RejectedTransactions(ctx context.Context) (*rpc.Subs for { select { case d := <-rejected: - notifier.Notify(rpcSub.ID, &rejectNotification{Tx: d.Tx, Reason: d.Reason.Error()}) + reason := "" + if d.Reason != nil { + reason = d.Reason.Error() + } + notifier.Notify(rpcSub.ID, &rejectNotification{Tx: d.Tx, Reason: reason}) case <-rpcSub.Err(): rejectedSub.Unsubscribe() return