Fix reversed range

This commit is contained in:
Nikita Meshcheriakov 2026-01-03 12:50:35 -03:00
parent b635e0632c
commit 715a328d3d
2 changed files with 3 additions and 7 deletions

View file

@ -471,10 +471,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{}
}

View file

@ -143,6 +143,9 @@ func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) {
if err != nil {
return nil, err
}
if begin > end {
return nil, errInvalidBlockRange
}
return f.rangeLogs(ctx, begin, end)
}
@ -383,9 +386,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()