mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
Modifying miner.recommit flag and its adjustment function. (#370)
* changed min/max/current recommit values * Remove Hardcoded min/max * Code Sanitization * Skipping tests for constant recommit interval * Adding default miner.recommit value * Minor Change
This commit is contained in:
parent
8c3423ca7c
commit
4fb3f5ddee
3 changed files with 27 additions and 19 deletions
|
|
@ -88,7 +88,7 @@ var Defaults = Config{
|
|||
Miner: miner.Config{
|
||||
GasCeil: 8000000,
|
||||
GasPrice: big.NewInt(params.GWei),
|
||||
Recommit: 3 * time.Second,
|
||||
Recommit: 125 * time.Second,
|
||||
},
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
RPCGasCap: 50000000,
|
||||
|
|
|
|||
|
|
@ -389,24 +389,27 @@ func (w *worker) close() {
|
|||
|
||||
// recalcRecommit recalculates the resubmitting interval upon feedback.
|
||||
func recalcRecommit(minRecommit, prev time.Duration, target float64, inc bool) time.Duration {
|
||||
var (
|
||||
prevF = float64(prev.Nanoseconds())
|
||||
next float64
|
||||
)
|
||||
if inc {
|
||||
next = prevF*(1-intervalAdjustRatio) + intervalAdjustRatio*(target+intervalAdjustBias)
|
||||
max := float64(maxRecommitInterval.Nanoseconds())
|
||||
if next > max {
|
||||
next = max
|
||||
}
|
||||
} else {
|
||||
next = prevF*(1-intervalAdjustRatio) + intervalAdjustRatio*(target-intervalAdjustBias)
|
||||
min := float64(minRecommit.Nanoseconds())
|
||||
if next < min {
|
||||
next = min
|
||||
}
|
||||
}
|
||||
return time.Duration(int64(next))
|
||||
// var (
|
||||
// prevF = float64(prev.Nanoseconds())
|
||||
// next float64
|
||||
// )
|
||||
// if inc {
|
||||
// next = prevF*(1-intervalAdjustRatio) + intervalAdjustRatio*(target+intervalAdjustBias)
|
||||
// max := float64(maxRecommitInterval.Nanoseconds())
|
||||
// if next > max {
|
||||
// next = max
|
||||
// }
|
||||
// } else {
|
||||
// next = prevF*(1-intervalAdjustRatio) + intervalAdjustRatio*(target-intervalAdjustBias)
|
||||
// min := float64(minRecommit.Nanoseconds())
|
||||
// if next < min {
|
||||
// next = min
|
||||
// }
|
||||
// }
|
||||
// log.Info("Recalc Commit", "Prev", prev, "Next", next)
|
||||
|
||||
//returning the Same prev value to keep the recommit interval constant
|
||||
return time.Duration(int64(prev))
|
||||
}
|
||||
|
||||
// newWorkLoop is a standalone goroutine to submit new sealing work upon received events.
|
||||
|
|
|
|||
|
|
@ -434,10 +434,15 @@ func testRegenerateMiningBlock(t *testing.T, chainConfig *params.ChainConfig, en
|
|||
}
|
||||
|
||||
func TestAdjustIntervalEthash(t *testing.T) {
|
||||
// Skipping this test as recommit interval would remain constant
|
||||
t.Skip()
|
||||
testAdjustInterval(t, ethashChainConfig, ethash.NewFaker())
|
||||
}
|
||||
|
||||
func TestAdjustIntervalClique(t *testing.T) {
|
||||
|
||||
// Skipping this test as recommit interval would remain constant
|
||||
t.Skip()
|
||||
testAdjustInterval(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue