Skip to content

Commit

Permalink
fix for evm main
Browse files Browse the repository at this point in the history
  • Loading branch information
Vizualni committed Jul 5, 2022
1 parent 7f548b8 commit d62387f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion chain/evm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ type ethClientToFilterLogs interface {
HeaderByNumber(ctx context.Context, number *big.Int) (*etherumtypes.Header, error)
}

func shouldDoBinarySearchFromError(err error) bool {

switch {
case strings.Contains(err.Error(), "query returned more than 10000 results"):
return true
case strings.Contains(err.Error(), "eth_getLogs and eth_newFilter are limited to a 10,000 blocks range"):
return true
}

return false
}

func filterLogs(
ctx context.Context,
ethClient ethClientToFilterLogs,
Expand Down Expand Up @@ -309,7 +321,7 @@ func filterLogs(
return true, nil
}
return fn(logs), nil
case err.Error() == "query returned more than 10000 results":
case shouldDoBinarySearchFromError(err):
// this appears to be ropsten specifict, but keepeing the logic here just in case
mid := big.NewInt(0).Sub(
fq.ToBlock,
Expand Down

0 comments on commit d62387f

Please sign in to comment.