mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
graphql: dev: chg: avoid greedy allocation on graphql blocks call (#958)
* dev: chg: avoid greedy allocation on graphql blocks call * dev: fix: linter issues
This commit is contained in:
parent
d4959497c8
commit
b4cc1f65be
1 changed files with 6 additions and 1 deletions
|
|
@ -1350,7 +1350,8 @@ func (r *Resolver) Blocks(ctx context.Context, args struct {
|
|||
return []*Block{}, nil
|
||||
}
|
||||
|
||||
ret := make([]*Block, 0, to-from+1)
|
||||
// nolint:prealloc
|
||||
var ret []*Block
|
||||
|
||||
for i := from; i <= to; i++ {
|
||||
numberOrHash := rpc.BlockNumberOrHashWithNumber(i)
|
||||
|
|
@ -1370,6 +1371,10 @@ func (r *Resolver) Blocks(ctx context.Context, args struct {
|
|||
}
|
||||
|
||||
ret = append(ret, block)
|
||||
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue