Skip to content

Commit 5e89ff4

Browse files
authored
graphql: validate block params (#27876)
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.
1 parent 86d7f5a commit 5e89ff4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

graphql/graphql.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,9 @@ func (r *Resolver) Block(ctx context.Context, args struct {
12171217
Number *Long
12181218
Hash *common.Hash
12191219
}) (*Block, error) {
1220+
if args.Number != nil && args.Hash != nil {
1221+
return nil, errors.New("only one of number or hash must be specified")
1222+
}
12201223
var numberOrHash rpc.BlockNumberOrHash
12211224
if args.Number != nil {
12221225
if *args.Number < 0 {

0 commit comments

Comments
 (0)