Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,6 @@ func (api *FilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*type
if crit.ToBlock != nil {
end = crit.ToBlock.Int64()
}
// Block numbers below 0 are special cases.
if begin > 0 && end > 0 && begin > end {
return nil, errInvalidBlockRange
}
if begin >= 0 && begin < int64(api.events.backend.HistoryPruningCutoff()) {
return nil, &history.PrunedHistoryError{}
}
Expand Down
17 changes: 11 additions & 6 deletions eth/filters/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,17 @@ func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) {
if err != nil {
return nil, err
}
end, err := resolveSpecial(f.end)
if err != nil {
return nil, err
var end uint64
if f.begin != f.end {
end, err = resolveSpecial(f.end)
if err != nil {
return nil, err
}
} else {
end = begin
}
if begin > end {
return nil, errInvalidBlockRange
}
if f.rangeLimit != 0 && (end-begin) > f.rangeLimit {
return nil, fmt.Errorf("exceed maximum block range: %d", f.rangeLimit)
Expand Down Expand Up @@ -389,9 +397,6 @@ func (f *Filter) rangeLogs(ctx context.Context, firstBlock, lastBlock uint64) ([
}()
}

if firstBlock > lastBlock {
return nil, nil
}
mb := f.sys.backend.NewMatcherBackend()
defer mb.Close()

Expand Down
7 changes: 6 additions & 1 deletion eth/filters/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,12 @@ func testFilters(t *testing.T, history uint64, noHistory bool) {
want: `[{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696333"],"data":"0x","blockNumber":"0x3e7","transactionHash":"0x53e3675800c6908424b61b35a44e51ca4c73ca603e58a65b32c67968b4f42200","transactionIndex":"0x0","blockHash":"0x2e4620a2b426b0612ec6cad9603f466723edaed87f98c9137405dd4f7a2409ff","blockTimestamp":"0x2706","logIndex":"0x0","removed":false}]`,
},
{
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil, 0),
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil, 0),
err: "invalid block range params",
},
{
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.EarliestBlockNumber), nil, nil, 0),
err: "invalid block range params",
},
{
f: sys.NewRangeFilter(int64(rpc.SafeBlockNumber), int64(rpc.LatestBlockNumber), nil, nil, 0),
Expand Down
Loading