Skip to content

Commit

Permalink
graphql: validate block params (#27876)
Browse files Browse the repository at this point in the history
Block takes a number and a hash. The spec is unclear on what should happen in this case, leaving it an implemenation detail. With this change, we return an error in case both number and hash are passed in.
  • Loading branch information
s1na committed Aug 10, 2023
1 parent 86d7f5a commit 5e89ff4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,9 @@ func (r *Resolver) Block(ctx context.Context, args struct {
Number *Long
Hash *common.Hash
}) (*Block, error) {
if args.Number != nil && args.Hash != nil {
return nil, errors.New("only one of number or hash must be specified")
}
var numberOrHash rpc.BlockNumberOrHash
if args.Number != nil {
if *args.Number < 0 {
Expand Down

0 comments on commit 5e89ff4

Please sign in to comment.