aboutsummaryrefslogtreecommitdiff
path: root/src/qt/modaloverlay.cpp
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2016-10-10 16:52:39 +0200
committerJonas Schnelli <dev@jonasschnelli.ch>2016-10-10 16:52:44 +0200
commitbf8e68aba68d7c6a4c17a5c05fa3fa61a8da2bdd (patch)
tree085b6a3e97a0273ea3d198a6da5e285008f074a5 /src/qt/modaloverlay.cpp
parent6429cfa8a70308241c576aeb92ffe3db5203b2ef (diff)
parentfa85e860a9261e6c585ec40e67845fa93a20c6e7 (diff)
Merge #8821: [qt] sync-overlay: Don't block during reindex
fa85e86 [qt] sync-overlay: Don't show estimated number of headers left (MarcoFalke) faa4de2 [qt] sync-overlay: Don't block during reindex (MarcoFalke)
Diffstat (limited to 'src/qt/modaloverlay.cpp')
-rw-r--r--src/qt/modaloverlay.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp
index 2de2dde16a..5caade7d38 100644
--- a/src/qt/modaloverlay.cpp
+++ b/src/qt/modaloverlay.cpp
@@ -13,7 +13,8 @@
ModalOverlay::ModalOverlay(QWidget *parent) :
QWidget(parent),
ui(new Ui::ModalOverlay),
-bestBlockHeight(0),
+bestHeaderHeight(0),
+bestHeaderDate(QDateTime()),
layerIsVisible(false),
userClosed(false)
{
@@ -65,14 +66,9 @@ bool ModalOverlay::event(QEvent* ev) {
void ModalOverlay::setKnownBestHeight(int count, const QDateTime& blockDate)
{
-
- /* only update the blockheight if the headerschain-tip is not older then 30 days */
- int64_t now = QDateTime::currentDateTime().toTime_t();
- int64_t btime = blockDate.toTime_t();
- if (btime+3600*24*30 > now)
- {
- if (count > bestBlockHeight)
- bestBlockHeight = count;
+ if (count > bestHeaderHeight) {
+ bestHeaderHeight = count;
+ bestHeaderDate = blockDate;
}
}
@@ -125,11 +121,21 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
ui->percentageProgress->setText(QString::number(nVerificationProgress*100, 'f', 2)+"%");
ui->progressBar->setValue(nVerificationProgress*100);
+ if (!bestHeaderDate.isValid())
+ // not syncing
+ return;
+
+ // estimate the number of headers left based on nPowTargetSpacing
+ // and check if the gui is not aware of the the best header (happens rarely)
+ int estimateNumHeadersLeft = bestHeaderDate.secsTo(currentDate) / 600;
+ bool hasBestHeader = bestHeaderHeight >= count;
+
// show remaining number of blocks
- if (bestBlockHeight > 0)
- ui->numberOfBlocksLeft->setText(QString::number(bestBlockHeight-count));
- else
+ if (estimateNumHeadersLeft < 24 && hasBestHeader) {
+ ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count));
+ } else {
ui->expectedTimeLeft->setText(tr("Unknown. Syncing Headers..."));
+ }
}
void ModalOverlay::showHide(bool hide, bool userRequested)