Skip to content

Commit

Permalink
tweak: Emit txs even if we fail to create a statedb.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-smith committed Dec 6, 2023
1 parent c6db8e6 commit bda0b19
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions eth/filters/trace_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,16 @@ func (api *FilterAPI) NewPendingTransactionsWithTrace(ctx context.Context, trace
blockNumber = hexutil.Big(*header.Number)
blockHash = header.Hash()
txIndex = hexutil.Uint64(0)

err error
statedb *state.StateDB
)

statedb, err := api.sys.chain.State()
// If we fail to get the statedb we continue. We'll guard usage of
// it against nils later.
statedb, err = api.sys.chain.State()
if err != nil {
log.Error("pending_txs_stream: failed to get state", "err", err)
return
}

metricsPendingTxsReceived.Inc(int64(len(txs)))
Expand All @@ -129,6 +133,11 @@ func (api *FilterAPI) NewPendingTransactionsWithTrace(ctx context.Context, trace
rpcTx.GasPrice = &gasPrice
tracedTxs = append(tracedTxs, rpcTx)

// If we failed to get a statedb earlier then skip tracing.g
if statedb == nil {
continue
}

msg, _ = core.TransactionToMessage(tx, signer, header.BaseFee)
if err != nil {
log.Error("pending_txs_stream: failed to create tx message", "err", err, "tx", tx.Hash())
Expand Down

0 comments on commit bda0b19

Please sign in to comment.