mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Fix division by zero in time remaining
This commit is contained in:
parent
50fae68d41
commit
3b69a08c53
@ -99,15 +99,18 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
|
|||||||
progressDelta = progressStart-sample.second;
|
progressDelta = progressStart-sample.second;
|
||||||
timeDelta = blockProcessTime[0].first - sample.first;
|
timeDelta = blockProcessTime[0].first - sample.first;
|
||||||
progressPerHour = progressDelta/(double)timeDelta*1000*3600;
|
progressPerHour = progressDelta/(double)timeDelta*1000*3600;
|
||||||
remainingMSecs = remainingProgress / progressDelta * timeDelta;
|
remainingMSecs = (progressDelta > 0) ? remainingProgress / progressDelta * timeDelta : -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// show progress increase per hour
|
// show progress increase per hour
|
||||||
ui->progressIncreasePerH->setText(QString::number(progressPerHour*100, 'f', 2)+"%");
|
ui->progressIncreasePerH->setText(QString::number(progressPerHour*100, 'f', 2)+"%");
|
||||||
|
|
||||||
// show expected remaining time
|
if(remainingMSecs >= 0) {
|
||||||
ui->expectedTimeLeft->setText(GUIUtil::formatNiceTimeOffset(remainingMSecs/1000.0));
|
ui->expectedTimeLeft->setText(GUIUtil::formatNiceTimeOffset(remainingMSecs / 1000.0));
|
||||||
|
} else {
|
||||||
|
ui->expectedTimeLeft->setText(QObject::tr("unknown"));
|
||||||
|
}
|
||||||
|
|
||||||
static const int MAX_SAMPLES = 5000;
|
static const int MAX_SAMPLES = 5000;
|
||||||
if (blockProcessTime.count() > MAX_SAMPLES)
|
if (blockProcessTime.count() > MAX_SAMPLES)
|
||||||
|
Loading…
Reference in New Issue
Block a user