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 lai8983166 committed Aug 13, 2024
1 parent 7f56720 commit b54baf2
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 @@ -41,7 +41,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 @@ -1203,7 +1204,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++ {
Expand Down

0 comments on commit b54baf2

Please sign in to comment.