diff --git a/gossip/gasprice/constructive.go b/gossip/gasprice/constructive.go index d9c0e7dbe..d7fb99aa2 100644 --- a/gossip/gasprice/constructive.go +++ b/gossip/gasprice/constructive.go @@ -77,14 +77,6 @@ func (gpo *Oracle) constructiveGasPriceOf(freeRatio uint64, adjustedMinPrice *bi multiplier := new(big.Int).SetUint64(freeRatioToConstructiveGasRatio(freeRatio)) // gas price = multiplier * adjustedMinPrice - tip := multiplier.Mul(multiplier, adjustedMinPrice) - tip.Div(tip, DecimalUnitBn) - - if tip.Cmp(gpo.cfg.MinGasPrice) < 0 { - return gpo.cfg.MinGasPrice - } - if tip.Cmp(gpo.cfg.MaxGasPrice) > 0 { - return gpo.cfg.MaxGasPrice - } - return tip + price := multiplier.Mul(multiplier, adjustedMinPrice) + return price.Div(price, DecimalUnitBn) } diff --git a/gossip/gasprice/gasprice.go b/gossip/gasprice/gasprice.go index 8d872d030..872f29d6a 100644 --- a/gossip/gasprice/gasprice.go +++ b/gossip/gasprice/gasprice.go @@ -139,6 +139,12 @@ func (gpo *Oracle) suggestTip(certainty uint64) *big.Int { constructive := gpo.constructiveGasPrice(gpo.c.totalGas(), 0.005*DecimalUnit+certainty/25, adjustedMinGasPrice) combined := math.BigMax(reactive, constructive) + if combined.Cmp(gpo.cfg.MinGasPrice) < 0 { + combined = gpo.cfg.MinGasPrice + } + if combined.Cmp(gpo.cfg.MaxGasPrice) > 0 { + combined = gpo.cfg.MaxGasPrice + } tip := new(big.Int).Sub(combined, minPrice) if tip.Sign() < 0 { diff --git a/gossip/gasprice/reactive.go b/gossip/gasprice/reactive.go index 17764642e..4c4464fbb 100644 --- a/gossip/gasprice/reactive.go +++ b/gossip/gasprice/reactive.go @@ -14,7 +14,7 @@ import ( const ( percentilesPerStat = 20 statUpdatePeriod = 1 * time.Second - statsBuffer = (12 * time.Second) / statUpdatePeriod + statsBuffer = int((12 * time.Second) / statUpdatePeriod) maxGasToIndex = 40000000 )