Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
internal/ethapi: don't query wallets at every execution of gas estima…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
holiman authored and elizabethengelman committed Dec 30, 2019
1 parent d946ff0 commit cc86617
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,18 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
}
cap = hi

// Set sender address or use a default if none specified
if args.From == nil {
if wallets := b.AccountManager().Wallets(); len(wallets) > 0 {
if accounts := wallets[0].Accounts(); len(accounts) > 0 {
args.From = &accounts[0].Address
}
}
}
// Use zero-address if none other is available
if args.From == nil {
args.From = &common.Address{}
}
// Create a helper to check if a gas allowance results in an executable transaction
executable := func(gas uint64) bool {
args.Gas = (*hexutil.Uint64)(&gas)
Expand Down

0 comments on commit cc86617

Please sign in to comment.