graphql: return error if block from>to (#28393)

As per discussion in ethereum/execution-apis#475
This commit is contained in:
Delweng 2023-10-23 23:25:26 +08:00 committed by devopsbo3
parent e90266a302
commit c637c84fc4

View file

@ -42,6 +42,7 @@ import (
var (
errBlockInvariant = errors.New("block objects must be instantiated with at least one of num or hash")
errInvalidBlockRange = errors.New("invalid from and to block combination: from > to")
)
type Long int64
@ -1333,7 +1334,7 @@ func (r *Resolver) Blocks(ctx context.Context, args struct {
to = rpc.BlockNumber(r.backend.CurrentBlock().Number.Int64())
}
if to < from {
return []*Block{}, nil
return nil, errInvalidBlockRange
}
var ret []*Block
for i := from; i <= to; i++ {