Handle recent difficulty adjustment estimate gracefully

fixes #927
This commit is contained in:
softsimon
2021-11-17 13:05:14 +04:00
parent 6ad4e655ea
commit d534c42c47
3 changed files with 24 additions and 17 deletions

View File

@@ -724,14 +724,16 @@ class Routes {
const nextRetargetHeight = blockHeight + remainingBlocks;
let difficultyChange = 0;
if (blocksInEpoch > 0) {
difficultyChange = (600 / (diff / blocksInEpoch ) - 1) * 100;
}
if (difficultyChange > 300) {
difficultyChange = 300;
}
if (difficultyChange < -75) {
difficultyChange = -75;
if (remainingBlocks < 1870) {
if (blocksInEpoch > 0) {
difficultyChange = (600 / (diff / blocksInEpoch ) - 1) * 100;
}
if (difficultyChange > 300) {
difficultyChange = 300;
}
if (difficultyChange < -75) {
difficultyChange = -75;
}
}
const timeAvgDiff = difficultyChange * 0.1;