diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp --- a/src/qt/modaloverlay.cpp +++ b/src/qt/modaloverlay.cpp @@ -73,7 +73,6 @@ // show progress speed if we have more then one sample if (blockProcessTime.size() >= 2) { - double progressStart = blockProcessTime[0].second; double progressDelta = 0; double progressPerHour = 0; qint64 timeDelta = 0; @@ -85,11 +84,14 @@ // take first sample after 500 seconds or last available one if (sample.first < (currentDate.toMSecsSinceEpoch() - 500 * 1000) || i == blockProcessTime.size() - 1) { - progressDelta = progressStart - sample.second; + progressDelta = blockProcessTime[0].second - sample.second; timeDelta = blockProcessTime[0].first - sample.first; progressPerHour = progressDelta / (double)timeDelta * 1000 * 3600; - remainingMSecs = remainingProgress / progressDelta * timeDelta; + remainingMSecs = + (progressDelta > 0) + ? remainingProgress / progressDelta * timeDelta + : -1; break; } } @@ -98,13 +100,18 @@ QString::number(progressPerHour * 100, 'f', 2) + "%"); // show expected remaining time - ui->expectedTimeLeft->setText( - GUIUtil::formatNiceTimeOffset(remainingMSecs / 1000.0)); + if (remainingMSecs >= 0) { + ui->expectedTimeLeft->setText( + GUIUtil::formatNiceTimeOffset(remainingMSecs / 1000.0)); + } else { + ui->expectedTimeLeft->setText(QObject::tr("unknown")); + } static const int MAX_SAMPLES = 5000; - if (blockProcessTime.count() > MAX_SAMPLES) + if (blockProcessTime.count() > MAX_SAMPLES) { blockProcessTime.remove(MAX_SAMPLES, blockProcessTime.count() - MAX_SAMPLES); + } } // show the last block date