Skip to content

Commit

Permalink
graphql: return error if block from>to (ethereum#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 Dergarcon committed Jan 31, 2024
1 parent 8e3a519 commit 542b543
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 @@ -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++ {
Expand Down

0 comments on commit 542b543

Please sign in to comment.