aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2016-09-13 16:36:24 +0200
committerJonas Schnelli <dev@jonasschnelli.ch>2016-09-13 17:57:25 +0200
commitd8b062ef5eea3addff00a09bad1dab162452b4b5 (patch)
treebc4a075d2557f3ea653ffc6b07540fc7653cce97 /src/qt
parente3245b43d5c6fc984e8c60495f6db54f85d64368 (diff)
downloadbitcoin-d8b062ef5eea3addff00a09bad1dab162452b4b5.tar.xz
[Qt] only update "amount of blocks left" when the header chain is in-sync
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/bitcoingui.cpp7
-rw-r--r--src/qt/clientmodel.cpp10
-rw-r--r--src/qt/clientmodel.h4
-rw-r--r--src/qt/forms/modaloverlay.ui3
-rw-r--r--src/qt/modaloverlay.cpp15
-rw-r--r--src/qt/modaloverlay.h2
6 files changed, 32 insertions, 9 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 628d35b5ea..c184745dbe 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -500,7 +500,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
setTrayIconVisible(optionsModel->getHideTrayIcon());
}
- modalOverlay->setKnownBestHeight(clientModel->getHeaderHeight());
+ modalOverlay->setKnownBestHeight(clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(clientModel->getHeaderTipTime()));
} else {
// Disable possibility to show main window via action
toggleHideAction->setEnabled(false);
@@ -718,7 +718,10 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
if (modalOverlay)
{
if (header)
- modalOverlay->setKnownBestHeight(count);
+ {
+ /* use clientmodels getHeaderTipHeight and getHeaderTipTime because the NotifyHeaderTip signal does not fire when updating the best header */
+ modalOverlay->setKnownBestHeight(clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(clientModel->getHeaderTipTime()));
+ }
else
modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
}
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index e3240b95a2..fb0cce59cc 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -68,7 +68,7 @@ int ClientModel::getNumBlocks() const
return chainActive.Height();
}
-int ClientModel::getHeaderHeight() const
+int ClientModel::getHeaderTipHeight() const
{
LOCK(cs_main);
if (!pindexBestHeader)
@@ -76,6 +76,14 @@ int ClientModel::getHeaderHeight() const
return pindexBestHeader->nHeight;
}
+int64_t ClientModel::getHeaderTipTime() const
+{
+ LOCK(cs_main);
+ if (!pindexBestHeader)
+ return 0;
+ return pindexBestHeader->GetBlockTime();
+}
+
quint64 ClientModel::getTotalBytesRecv() const
{
return CNode::GetTotalBytesRecv();
diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h
index f0c9a7988a..3fd8404cbb 100644
--- a/src/qt/clientmodel.h
+++ b/src/qt/clientmodel.h
@@ -51,8 +51,8 @@ public:
//! Return number of connections, default is in- and outbound (total)
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
int getNumBlocks() const;
- int getHeaderHeight() const;
-
+ int getHeaderTipHeight() const;
+ int64_t getHeaderTipTime() const;
//! Return number of transactions in the mempool
long getMempoolSize() const;
//! Return the dynamic memory usage of the mempool
diff --git a/src/qt/forms/modaloverlay.ui b/src/qt/forms/modaloverlay.ui
index f1967a7c05..ce9ceaaadd 100644
--- a/src/qt/forms/modaloverlay.ui
+++ b/src/qt/forms/modaloverlay.ui
@@ -82,6 +82,9 @@ QLabel { color: rgb(40,40,40); }</string>
</property>
<item>
<widget class="QPushButton" name="warningIcon">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string/>
</property>
diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp
index 1cd5b19966..c548890391 100644
--- a/src/qt/modaloverlay.cpp
+++ b/src/qt/modaloverlay.cpp
@@ -63,10 +63,17 @@ bool ModalOverlay::event(QEvent* ev) {
return QWidget::event(ev);
}
-void ModalOverlay::setKnownBestHeight(int count)
+void ModalOverlay::setKnownBestHeight(int count, const QDateTime& blockDate)
{
- if (count > bestBlockHeight)
- bestBlockHeight = count;
+
+ /* 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;
+ }
}
void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVerificationProgress)
@@ -122,6 +129,8 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
// show remaining amount of blocks
if (bestBlockHeight > 0)
ui->amountOfBlocksLeft->setText(QString::number(bestBlockHeight-count));
+ else
+ ui->expectedTimeLeft->setText(tr("Unknown. Syncing Headers..."));
}
void ModalOverlay::showHide(bool hide, bool userRequested)
diff --git a/src/qt/modaloverlay.h b/src/qt/modaloverlay.h
index 5bf913a3f3..bdbe3c39a7 100644
--- a/src/qt/modaloverlay.h
+++ b/src/qt/modaloverlay.h
@@ -23,7 +23,7 @@ public:
public Q_SLOTS:
void tipUpdate(int count, const QDateTime& blockDate, double nVerificationProgress);
- void setKnownBestHeight(int count);
+ void setKnownBestHeight(int count, const QDateTime& blockDate);
// will show or hide the modal layer
void showHide(bool hide = false, bool userRequested = false);