From 0e0ed4ec64e6f985a9f3fc3ca85469b5f95a7360 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 11 Nov 2019 12:12:19 +0100 Subject: [PATCH] internal/ethapi: don't query wallets at every execution of gas estimation --- internal/ethapi/api.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9ac5be8c8..e8c935c1c 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -908,6 +908,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)