Skip to content

Commit

Permalink
limit range get log
Browse files Browse the repository at this point in the history
  • Loading branch information
unclezoro committed Mar 4, 2021
1 parent 7f7d1bb commit f7ff554
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions eth/filters/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package filters
import (
"context"
"errors"
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -30,6 +31,8 @@ import (
"github.com/ethereum/go-ethereum/rpc"
)

const maxFilterBlockRange = 5000

type Backend interface {
ChainDb() ethdb.Database
HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)
Expand Down Expand Up @@ -142,6 +145,9 @@ func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) {
if f.end == -1 {
end = head
}
if (int64(end) - f.begin) > maxFilterBlockRange {
return nil, fmt.Errorf("exceed maximum block range: %d", maxFilterBlockRange)
}
// Gather all indexed logs, and finish with non indexed ones
var (
logs []*types.Log
Expand Down

0 comments on commit f7ff554

Please sign in to comment.