mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
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.
This commit is contained in:
parent
13144f4a23
commit
639618350d
1 changed files with 3 additions and 0 deletions
|
|
@ -1217,6 +1217,9 @@ func (r *Resolver) Block(ctx context.Context, args struct {
|
||||||
Number *Long
|
Number *Long
|
||||||
Hash *common.Hash
|
Hash *common.Hash
|
||||||
}) (*Block, error) {
|
}) (*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
|
var numberOrHash rpc.BlockNumberOrHash
|
||||||
if args.Number != nil {
|
if args.Number != nil {
|
||||||
if *args.Number < 0 {
|
if *args.Number < 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue