core, eth: Only show rejections if err is not nil

This commit is contained in:
Austin Roberts 2020-04-08 14:22:12 -05:00
parent 4eab5b8213
commit 2791b22d83
2 changed files with 12 additions and 6 deletions

View file

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

View file

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