mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
add multiple gas estimation
This commit is contained in:
parent
7dd3194710
commit
93c782a830
2 changed files with 15 additions and 0 deletions
|
|
@ -945,6 +945,20 @@ func (p *Pending) EstimateGas(ctx context.Context, args struct {
|
|||
return ethapi.DoEstimateGas(ctx, p.backend, args.Data, rpc.PendingBlockNumber)
|
||||
}
|
||||
|
||||
func (p *Pending) EstimateGases(ctx context.Context, args struct {
|
||||
Data *[]ethapi.CallArgs
|
||||
}) (*[]hexutil.Uint64, error) {
|
||||
ret := make([]hexutil.Uint64, 0, len(*args.Data))
|
||||
for _, call := range *args.Data {
|
||||
estimatedGas, err := ethapi.DoEstimateGas(ctx, p.backend, call, rpc.PendingBlockNumber)
|
||||
if err != nil {
|
||||
return &ret, nil
|
||||
}
|
||||
ret = append(ret, estimatedGas)
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
// Resolver is the top-level object in the GraphQL hierarchy.
|
||||
type Resolver struct {
|
||||
backend *eth.EthAPIBackend
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ const schema string = `
|
|||
# EstimateGas estimates the amount of gas that will be required for
|
||||
# successful execution of a transaction for the pending state.
|
||||
estimateGas(data: CallData!): Long!
|
||||
estimateGases(data: [CallData!]): [Long!]
|
||||
}
|
||||
|
||||
type Query {
|
||||
|
|
|
|||
Loading…
Reference in a new issue