mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
Merge 8e48f336ed into 406a852ec8
This commit is contained in:
commit
9c45ab5697
3 changed files with 17 additions and 11 deletions
|
|
@ -473,10 +473,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{}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Reference in a new issue