mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-05 07:42:57 +00:00
graphql: return error if block from>to (#28393)
As per discussion in ethereum/execution-apis#475
This commit is contained in:
parent
3853f50082
commit
43e6a3c196
1 changed files with 3 additions and 2 deletions
|
|
@ -41,7 +41,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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
|
type Long int64
|
||||||
|
|
@ -1333,7 +1334,7 @@ func (r *Resolver) Blocks(ctx context.Context, args struct {
|
||||||
to = rpc.BlockNumber(r.backend.CurrentBlock().Number.Int64())
|
to = rpc.BlockNumber(r.backend.CurrentBlock().Number.Int64())
|
||||||
}
|
}
|
||||||
if to < from {
|
if to < from {
|
||||||
return []*Block{}, nil
|
return nil, errInvalidBlockRange
|
||||||
}
|
}
|
||||||
var ret []*Block
|
var ret []*Block
|
||||||
for i := from; i <= to; i++ {
|
for i := from; i <= to; i++ {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue