mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
accounts, internal: extend log message
This commit is contained in:
parent
1dbb69c692
commit
ec6a8df988
2 changed files with 14 additions and 12 deletions
|
|
@ -404,18 +404,19 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
|
|||
}
|
||||
// Recap the highest gas allowance with account's balance.
|
||||
if call.GasPrice != nil && call.GasPrice.Uint64() != 0 {
|
||||
balance := new(big.Int)
|
||||
balance.Set(b.pendingState.GetBalance(call.From)) // from can't be nil
|
||||
balance := b.pendingState.GetBalance(call.From) // from can't be nil
|
||||
available := new(big.Int).Set(balance)
|
||||
if call.Value != nil {
|
||||
if call.Value.Cmp(balance) >= 0 {
|
||||
if call.Value.Cmp(available) >= 0 {
|
||||
return 0, errors.New("insufficient funds for transfer")
|
||||
}
|
||||
balance.Sub(balance, call.Value)
|
||||
available.Sub(available, call.Value)
|
||||
}
|
||||
allowance := new(big.Int).Div(balance, call.GasPrice)
|
||||
allowance := new(big.Int).Div(available, call.GasPrice)
|
||||
if hi > allowance.Uint64() {
|
||||
log.Warn("Gas estimation capped by limited funds", "original", hi, "balance", balance,
|
||||
"sent", call.Value, "gasprice", call.GasPrice, "fundable", allowance)
|
||||
hi = allowance.Uint64()
|
||||
log.Warn("Gas estimation capped by limited funds", "original", hi, "fundable", allowance)
|
||||
}
|
||||
}
|
||||
cap = hi
|
||||
|
|
|
|||
|
|
@ -927,18 +927,19 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
balance := new(big.Int)
|
||||
balance.Set(state.GetBalance(*args.From)) // from can't be nil
|
||||
balance := state.GetBalance(*args.From) // from can't be nil
|
||||
available := new(big.Int).Set(balance)
|
||||
if args.Value != nil {
|
||||
if args.Value.ToInt().Cmp(balance) >= 0 {
|
||||
if args.Value.ToInt().Cmp(available) >= 0 {
|
||||
return 0, errors.New("insufficient funds for transfer")
|
||||
}
|
||||
balance.Sub(balance, args.Value.ToInt())
|
||||
available.Sub(available, args.Value.ToInt())
|
||||
}
|
||||
allowance := new(big.Int).Div(balance, args.GasPrice.ToInt())
|
||||
allowance := new(big.Int).Div(available, args.GasPrice.ToInt())
|
||||
if hi > allowance.Uint64() {
|
||||
log.Warn("Gas estimation capped by limited funds", "original", hi, "balance", balance,
|
||||
"sent", args.Value, "gasprice", args.GasPrice, "fundable", allowance)
|
||||
hi = allowance.Uint64()
|
||||
log.Warn("Gas estimation capped by limited funds", "original", hi, "fundable", allowance)
|
||||
}
|
||||
}
|
||||
// Recap the highest gas allowance with specified gascap.
|
||||
|
|
|
|||
Loading…
Reference in a new issue