Slightly better gas estimator math

This commit is contained in:
Łukasz Magiera 2020-08-01 13:23:07 +02:00
parent 90baf06011
commit 5bfee9875c

View File

@ -83,14 +83,16 @@ func (a *GasAPI) GasEstimateGasPrice(ctx context.Context, nblocksincl uint64,
// todo: account for how full blocks are // todo: account for how full blocks are
at := gasUsed / 2 at := gasUsed / 2
prev := big.Zero()
for _, price := range prices { for _, price := range prices {
at -= price.used at -= price.used
if at > 0 { if at > 0 {
prev = price.price
continue continue
} }
return price.price, nil return types.BigAdd(big.Div(types.BigAdd(price.price, prev), types.NewInt(2)), big.NewInt(1)), nil
} }
switch nblocksincl { switch nblocksincl {