Skip to content

Commit

Permalink
fix default value for fromBlock when calling eth_getLogs (0xPolygonHe…
Browse files Browse the repository at this point in the history
  • Loading branch information
tclemos authored Jan 16, 2024
1 parent f42895b commit 8c526ae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions jsonrpc/endpoints_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ func (e *EthEndpoints) GetFilterChanges(filterID string) (interface{}, types.Err
case FilterTypeLog:
{
filterParameters := filter.Parameters.(LogFilter)
if filterParameters.FromBlock == nil {
bn := types.BlockNumber(0)
filterParameters.FromBlock = &bn
}
filterParameters.Since = &filter.LastPoll

resInterface, err := e.internalGetLogs(context.Background(), nil, filterParameters)
Expand Down Expand Up @@ -485,6 +489,11 @@ func (e *EthEndpoints) GetLogs(filter LogFilter) (interface{}, types.Error) {
}

func (e *EthEndpoints) internalGetLogs(ctx context.Context, dbTx pgx.Tx, filter LogFilter) (interface{}, types.Error) {
if filter.FromBlock == nil {
l := types.LatestBlockNumber
filter.FromBlock = &l
}

fromBlockNumber, toBlockNumber, rpcErr := filter.GetNumericBlockNumbers(ctx, e.cfg, e.state, e.etherman, dbTx)
if rpcErr != nil {
return nil, rpcErr
Expand Down

0 comments on commit 8c526ae

Please sign in to comment.