Commit 785ef85b authored by Christopher Schinnerl's avatar Christopher Schinnerl

fix difficulty adjustment

parent f383ad69
Pipeline #33923966 passed with stages
in 28 minutes and 4 seconds
......@@ -131,10 +131,10 @@ func (cs *ConsensusSet) childTargetOak(parentTotalTime int64, parentTotalTarget,
maxNewTarget := currentTarget.MulDifficulty(types.OakMaxRise) // Max = difficulty increase (target decrease)
minNewTarget := currentTarget.MulDifficulty(types.OakMaxDrop) // Min = difficulty decrease (target increase)
newTarget := types.RatToTarget(new(big.Rat).SetFrac(types.RootDepth.Int(), visibleHashrate.Mul64(uint64(targetBlockTime)).Big()))
if newTarget.Cmp(maxNewTarget) < 0 {
if newTarget.Cmp(maxNewTarget) < 0 && parentHeight+1 != types.ASICHardforkHeight {
newTarget = maxNewTarget
}
if newTarget.Cmp(minNewTarget) > 0 {
if newTarget.Cmp(minNewTarget) > 0 && parentHeight+1 != types.ASICHardforkHeight {
// This can only possibly trigger if the BlockFrequency is less than 3
// seconds, but during testing it is 1 second.
newTarget = minNewTarget
......@@ -182,7 +182,7 @@ func (cs *ConsensusSet) storeBlockTotals(tx *bolt.Tx, currentHeight types.BlockH
// At the hardfork height to adjust the acceptable nonce conditions, reset
// the total time and total target.
if currentHeight == types.ASICHardforkHeight {
if currentHeight+1 == types.ASICHardforkHeight {
newTotalTime = types.ASICHardforkTotalTime
newTotalTarget = types.ASICHardforkTotalTarget
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment