Skip to content

Commit

Permalink
graphql: return error if block from>to (#28393)
Browse files Browse the repository at this point in the history
As per discussion in ethereum/execution-apis#475
  • Loading branch information
jsvisa authored and isman-usoh committed May 27, 2024
1 parent 8ee5455 commit 457b50b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import (
)

var (
errBlockInvariant = errors.New("block objects must be instantiated with at least one of num or hash")
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
Expand Down Expand Up @@ -1105,7 +1106,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
}
ret := make([]*Block, 0, to-from+1)
for i := from; i <= to; i++ {
Expand Down

0 comments on commit 457b50b

Please sign in to comment.