Skip to content

Commit

Permalink
Update endpoints_eth.go
Browse files Browse the repository at this point in the history
fix

fix
  • Loading branch information
scf0220 committed Nov 26, 2023
1 parent 369582a commit 80e01ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions jsonrpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type Config struct {
// EnableHttpLog allows the user to enable or disable the logs related to the HTTP
// requests to be captured by the server.
EnableHttpLog bool `mapstructure:"EnableHttpLog"`
// EnablePendingTransactionFilter enables pending transaction filter that can support query L2 pending transaction
EnablePendingTransactionFilter bool `mapstructure:"EnablePendingTransactionFilter"`
}

// WebSocketsConfig has parameters to config the rpc websocket support
Expand Down
4 changes: 2 additions & 2 deletions jsonrpc/endpoints_debug_innertx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (d *DebugEndpoints) buildInnerTransaction(ctx context.Context, hash common.

// check tracer
if traceCfg.Tracer != nil && *traceCfg.Tracer != "" && !isBuiltInTracer(*traceCfg.Tracer) && !isJSCustomTracer(*traceCfg.Tracer) {
return RPCErrorResponse(types.DefaultErrorCode, "invalid tracer", nil)
return RPCErrorResponse(types.DefaultErrorCode, "invalid tracer", nil, true)
}

stateTraceConfig := state.TraceConfig{
Expand All @@ -31,7 +31,7 @@ func (d *DebugEndpoints) buildInnerTransaction(ctx context.Context, hash common.
}
result, err := d.state.DebugTransaction(ctx, hash, stateTraceConfig, dbTx)
if errors.Is(err, state.ErrNotFound) {
return RPCErrorResponse(types.DefaultErrorCode, "transaction not found", nil)
return RPCErrorResponse(types.DefaultErrorCode, "transaction not found", nil, true)
} else if err != nil {
const errorMessage = "failed to get trace"
log.Errorf("%v: %v", errorMessage, err)
Expand Down
15 changes: 8 additions & 7 deletions jsonrpc/endpoints_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,13 +863,14 @@ func (e *EthEndpoints) NewPendingTransactionFilter() (interface{}, types.Error)

// internal
func (e *EthEndpoints) newPendingTransactionFilter(wsConn *concurrentWsConn) (interface{}, types.Error) {
return nil, types.NewRPCError(types.DefaultErrorCode, "not supported yet")
// id, err := e.storage.NewPendingTransactionFilter(wsConn)
// if err != nil {
// return rpcErrorResponse(types.DefaultErrorCode, "failed to create new pending transaction filter", err)
// }

// return id, nil
if !e.cfg.EnablePendingTransactionFilter {
return nil, types.NewRPCError(types.DefaultErrorCode, "not supported yet")
}
id, err := e.storage.NewPendingTransactionFilter(wsConn)
if err != nil {
return RPCErrorResponse(types.DefaultErrorCode, "failed to create new pending transaction filter", err, true)
}
return id, nil
}

// SendRawTransaction has two different ways to handle new transactions:
Expand Down

0 comments on commit 80e01ce

Please sign in to comment.