Changeset View
Changeset View
Standalone View
Standalone View
src/qt/modaloverlay.cpp
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | void ModalOverlay::tipUpdate(int count, const QDateTime &blockDate, | ||||
QDateTime currentDate = QDateTime::currentDateTime(); | QDateTime currentDate = QDateTime::currentDateTime(); | ||||
// keep a vector of samples of verification progress at height | // keep a vector of samples of verification progress at height | ||||
blockProcessTime.push_front( | blockProcessTime.push_front( | ||||
qMakePair(currentDate.toMSecsSinceEpoch(), nVerificationProgress)); | qMakePair(currentDate.toMSecsSinceEpoch(), nVerificationProgress)); | ||||
// show progress speed if we have more then one sample | // show progress speed if we have more then one sample | ||||
if (blockProcessTime.size() >= 2) { | if (blockProcessTime.size() >= 2) { | ||||
double progressStart = blockProcessTime[0].second; | |||||
double progressDelta = 0; | double progressDelta = 0; | ||||
double progressPerHour = 0; | double progressPerHour = 0; | ||||
qint64 timeDelta = 0; | qint64 timeDelta = 0; | ||||
qint64 remainingMSecs = 0; | qint64 remainingMSecs = 0; | ||||
double remainingProgress = 1.0 - nVerificationProgress; | double remainingProgress = 1.0 - nVerificationProgress; | ||||
for (int i = 1; i < blockProcessTime.size(); i++) { | for (int i = 1; i < blockProcessTime.size(); i++) { | ||||
QPair<qint64, double> sample = blockProcessTime[i]; | QPair<qint64, double> sample = blockProcessTime[i]; | ||||
// take first sample after 500 seconds or last available one | // take first sample after 500 seconds or last available one | ||||
if (sample.first < (currentDate.toMSecsSinceEpoch() - 500 * 1000) || | if (sample.first < (currentDate.toMSecsSinceEpoch() - 500 * 1000) || | ||||
i == blockProcessTime.size() - 1) { | i == blockProcessTime.size() - 1) { | ||||
progressDelta = progressStart - sample.second; | progressDelta = blockProcessTime[0].second - sample.second; | ||||
timeDelta = blockProcessTime[0].first - sample.first; | timeDelta = blockProcessTime[0].first - sample.first; | ||||
progressPerHour = | progressPerHour = | ||||
progressDelta / (double)timeDelta * 1000 * 3600; | 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( | ui->progressIncreasePerH->setText( | ||||
QString::number(progressPerHour * 100, 'f', 2) + "%"); | QString::number(progressPerHour * 100, 'f', 2) + "%"); | ||||
// show expected remaining time | // show expected remaining time | ||||
if (remainingMSecs >= 0) { | |||||
ui->expectedTimeLeft->setText( | ui->expectedTimeLeft->setText( | ||||
GUIUtil::formatNiceTimeOffset(remainingMSecs / 1000.0)); | 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) { | ||||
blockProcessTime.remove(MAX_SAMPLES, | blockProcessTime.remove(MAX_SAMPLES, | ||||
blockProcessTime.count() - MAX_SAMPLES); | blockProcessTime.count() - MAX_SAMPLES); | ||||
} | } | ||||
} | |||||
// show the last block date | // show the last block date | ||||
ui->newestBlockDate->setText(blockDate.toString()); | ui->newestBlockDate->setText(blockDate.toString()); | ||||
// show the percentage done according to nVerificationProgress | // show the percentage done according to nVerificationProgress | ||||
ui->percentageProgress->setText( | ui->percentageProgress->setText( | ||||
QString::number(nVerificationProgress * 100, 'f', 2) + "%"); | QString::number(nVerificationProgress * 100, 'f', 2) + "%"); | ||||
ui->progressBar->setValue(nVerificationProgress * 100); | ui->progressBar->setValue(nVerificationProgress * 100); | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |