mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Merge #15091: GUI: fix model overlay header sync
e8db6b8044424a6fbb4b0a80acffc8c7fbf6be8b Qt: Fix update headers-count (Jonas Schnelli) 7bb45e4b7a71e0ff0e2bbeba5367022758efa5d4 Qt: update header count regardless of update delay (Jonas Schnelli) Pull request description: Update the block and header tip is constraint to have a minimal distance of 250ms between updates... which can lead to miss the last header update. The modal overlay then assumes we are still in header sync and the view get stuck in "syncing headers,..." (while it's actually syncing blocks). This removes the 250ms minimal delta for header updates as well as it fixes the correct display of how header updates should update the labels. Tree-SHA512: 57608dac822b135cd604fc6ba1c80f25c0202a6e20bb140362026615d4bf243ef4fcc254a11bad36419c554a222a2f4947438d4ce44aa14041d1874751643d68
This commit is contained in:
parent
7c3c6ef71f
commit
03f2c9f8f0
@ -263,8 +263,8 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, int heig
|
|||||||
clientmodel->cachedBestHeaderHeight = height;
|
clientmodel->cachedBestHeaderHeight = height;
|
||||||
clientmodel->cachedBestHeaderTime = blockTime;
|
clientmodel->cachedBestHeaderTime = blockTime;
|
||||||
}
|
}
|
||||||
// if we are in-sync, update the UI regardless of last update time
|
// if we are in-sync or if we notify a header update, update the UI regardless of last update time
|
||||||
if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
|
if (fHeader || !initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
|
||||||
//pass an async signal to the UI thread
|
//pass an async signal to the UI thread
|
||||||
QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
|
||||||
Q_ARG(int, height),
|
Q_ARG(int, height),
|
||||||
|
@ -85,6 +85,7 @@ void ModalOverlay::setKnownBestHeight(int count, const QDateTime& blockDate)
|
|||||||
if (count > bestHeaderHeight) {
|
if (count > bestHeaderHeight) {
|
||||||
bestHeaderHeight = count;
|
bestHeaderHeight = count;
|
||||||
bestHeaderDate = blockDate;
|
bestHeaderDate = blockDate;
|
||||||
|
UpdateHeaderSyncLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,11 +151,16 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
|
|||||||
if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) {
|
if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) {
|
||||||
ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count));
|
ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count));
|
||||||
} else {
|
} else {
|
||||||
ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1)...").arg(bestHeaderHeight));
|
UpdateHeaderSyncLabel();
|
||||||
ui->expectedTimeLeft->setText(tr("Unknown..."));
|
ui->expectedTimeLeft->setText(tr("Unknown..."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModalOverlay::UpdateHeaderSyncLabel() {
|
||||||
|
int est_headers_left = bestHeaderDate.secsTo(QDateTime::currentDateTime()) / Params().GetConsensus().nPowTargetSpacing;
|
||||||
|
ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1, %2%)...").arg(bestHeaderHeight).arg(QString::number(100.0 / (bestHeaderHeight + est_headers_left) * bestHeaderHeight, 'f', 1)));
|
||||||
|
}
|
||||||
|
|
||||||
void ModalOverlay::toggleVisibility()
|
void ModalOverlay::toggleVisibility()
|
||||||
{
|
{
|
||||||
showHide(layerIsVisible, true);
|
showHide(layerIsVisible, true);
|
||||||
|
@ -47,6 +47,7 @@ private:
|
|||||||
bool layerIsVisible;
|
bool layerIsVisible;
|
||||||
bool userClosed;
|
bool userClosed;
|
||||||
bool foreverHidden;
|
bool foreverHidden;
|
||||||
|
void UpdateHeaderSyncLabel();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_QT_MODALOVERLAY_H
|
#endif // BITCOIN_QT_MODALOVERLAY_H
|
||||||
|
Loading…
Reference in New Issue
Block a user