[Qt] only update "amount of blocks left" when the header chain is in-sync
This commit is contained in:
parent
e3245b43d5
commit
d8b062ef5e
6 changed files with 32 additions and 9 deletions
|
@ -500,7 +500,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
|
||||||
setTrayIconVisible(optionsModel->getHideTrayIcon());
|
setTrayIconVisible(optionsModel->getHideTrayIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
modalOverlay->setKnownBestHeight(clientModel->getHeaderHeight());
|
modalOverlay->setKnownBestHeight(clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(clientModel->getHeaderTipTime()));
|
||||||
} else {
|
} else {
|
||||||
// Disable possibility to show main window via action
|
// Disable possibility to show main window via action
|
||||||
toggleHideAction->setEnabled(false);
|
toggleHideAction->setEnabled(false);
|
||||||
|
@ -718,7 +718,10 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
|
||||||
if (modalOverlay)
|
if (modalOverlay)
|
||||||
{
|
{
|
||||||
if (header)
|
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
|
else
|
||||||
modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
|
modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ int ClientModel::getNumBlocks() const
|
||||||
return chainActive.Height();
|
return chainActive.Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClientModel::getHeaderHeight() const
|
int ClientModel::getHeaderTipHeight() const
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
if (!pindexBestHeader)
|
if (!pindexBestHeader)
|
||||||
|
@ -76,6 +76,14 @@ int ClientModel::getHeaderHeight() const
|
||||||
return pindexBestHeader->nHeight;
|
return pindexBestHeader->nHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t ClientModel::getHeaderTipTime() const
|
||||||
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
|
if (!pindexBestHeader)
|
||||||
|
return 0;
|
||||||
|
return pindexBestHeader->GetBlockTime();
|
||||||
|
}
|
||||||
|
|
||||||
quint64 ClientModel::getTotalBytesRecv() const
|
quint64 ClientModel::getTotalBytesRecv() const
|
||||||
{
|
{
|
||||||
return CNode::GetTotalBytesRecv();
|
return CNode::GetTotalBytesRecv();
|
||||||
|
|
|
@ -51,8 +51,8 @@ public:
|
||||||
//! Return number of connections, default is in- and outbound (total)
|
//! Return number of connections, default is in- and outbound (total)
|
||||||
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
|
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
|
||||||
int getNumBlocks() const;
|
int getNumBlocks() const;
|
||||||
int getHeaderHeight() const;
|
int getHeaderTipHeight() const;
|
||||||
|
int64_t getHeaderTipTime() const;
|
||||||
//! Return number of transactions in the mempool
|
//! Return number of transactions in the mempool
|
||||||
long getMempoolSize() const;
|
long getMempoolSize() const;
|
||||||
//! Return the dynamic memory usage of the mempool
|
//! Return the dynamic memory usage of the mempool
|
||||||
|
|
|
@ -82,6 +82,9 @@ QLabel { color: rgb(40,40,40); }</string>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="warningIcon">
|
<widget class="QPushButton" name="warningIcon">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -63,10 +63,17 @@ bool ModalOverlay::event(QEvent* ev) {
|
||||||
return QWidget::event(ev);
|
return QWidget::event(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModalOverlay::setKnownBestHeight(int count)
|
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)
|
if (count > bestBlockHeight)
|
||||||
bestBlockHeight = count;
|
bestBlockHeight = count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVerificationProgress)
|
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
|
// show remaining amount of blocks
|
||||||
if (bestBlockHeight > 0)
|
if (bestBlockHeight > 0)
|
||||||
ui->amountOfBlocksLeft->setText(QString::number(bestBlockHeight-count));
|
ui->amountOfBlocksLeft->setText(QString::number(bestBlockHeight-count));
|
||||||
|
else
|
||||||
|
ui->expectedTimeLeft->setText(tr("Unknown. Syncing Headers..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModalOverlay::showHide(bool hide, bool userRequested)
|
void ModalOverlay::showHide(bool hide, bool userRequested)
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void tipUpdate(int count, const QDateTime& blockDate, double nVerificationProgress);
|
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
|
// will show or hide the modal layer
|
||||||
void showHide(bool hide = false, bool userRequested = false);
|
void showHide(bool hide = false, bool userRequested = false);
|
||||||
|
|
Loading…
Reference in a new issue