Skip to content

Commit c637c84

Browse files
jsvisadevopsbo3
authored andcommitted
graphql: return error if block from>to (ethereum#28393)
As per discussion in ethereum/execution-apis#475
1 parent e90266a commit c637c84

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

graphql/graphql.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ import (
4141
)
4242

4343
var (
44-
errBlockInvariant = errors.New("block objects must be instantiated with at least one of num or hash")
44+
errBlockInvariant = errors.New("block objects must be instantiated with at least one of num or hash")
45+
errInvalidBlockRange = errors.New("invalid from and to block combination: from > to")
4546
)
4647

4748
type Long int64
@@ -1333,7 +1334,7 @@ func (r *Resolver) Blocks(ctx context.Context, args struct {
13331334
to = rpc.BlockNumber(r.backend.CurrentBlock().Number.Int64())
13341335
}
13351336
if to < from {
1336-
return []*Block{}, nil
1337+
return nil, errInvalidBlockRange
13371338
}
13381339
var ret []*Block
13391340
for i := from; i <= to; i++ {

0 commit comments

Comments
 (0)