Skip to content

Commit

Permalink
add switch for pending transaction filter (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyh169 authored Oct 12, 2023
1 parent 401e252 commit 49481a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions jsonrpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type Config struct {
// TraceBatchUseHTTPS enables, in the debug_traceBatchByNum endpoint, the use of the HTTPS protocol (instead of HTTP)
// to do the parallel requests to RPC.debug_traceTransaction endpoint
TraceBatchUseHTTPS bool `mapstructure:"TraceBatchUseHTTPS"`

// 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
15 changes: 8 additions & 7 deletions jsonrpc/endpoints_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,13 +830,14 @@ func (e *EthEndpoints) NewPendingTransactionFilter() (interface{}, types.Error)

// internal
func (e *EthEndpoints) newPendingTransactionFilter(wsConn *websocket.Conn) (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)
}
return id, nil
}

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

0 comments on commit 49481a5

Please sign in to comment.