add multiple gas estimation

This commit is contained in:
Kosala Hemachandra 2019-04-04 22:49:14 -07:00
parent 7dd3194710
commit 93c782a830
No known key found for this signature in database
GPG key ID: 619BCBDAA716E153
2 changed files with 15 additions and 0 deletions

View file

@ -945,6 +945,20 @@ func (p *Pending) EstimateGas(ctx context.Context, args struct {
return ethapi.DoEstimateGas(ctx, p.backend, args.Data, rpc.PendingBlockNumber) 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. // Resolver is the top-level object in the GraphQL hierarchy.
type Resolver struct { type Resolver struct {
backend *eth.EthAPIBackend backend *eth.EthAPIBackend

View file

@ -289,6 +289,7 @@ const schema string = `
# EstimateGas estimates the amount of gas that will be required for # EstimateGas estimates the amount of gas that will be required for
# successful execution of a transaction for the pending state. # successful execution of a transaction for the pending state.
estimateGas(data: CallData!): Long! estimateGas(data: CallData!): Long!
estimateGases(data: [CallData!]): [Long!]
} }
type Query { type Query {