Skip to content

Commit bf8e68a

Browse files
committed
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)
2 parents 6429cfa + fa85e86 commit bf8e68a

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/qt/clientmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB
256256
int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
257257

258258
// if we are in-sync, update the UI regardless of last update time
259-
if (fHeader || !initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
259+
if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
260260
//pass a async signal to the UI thread
261261
QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
262262
Q_ARG(int, pIndex->nHeight),

src/qt/modaloverlay.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
ModalOverlay::ModalOverlay(QWidget *parent) :
1414
QWidget(parent),
1515
ui(new Ui::ModalOverlay),
16-
bestBlockHeight(0),
16+
bestHeaderHeight(0),
17+
bestHeaderDate(QDateTime()),
1718
layerIsVisible(false),
1819
userClosed(false)
1920
{
@@ -65,14 +66,9 @@ bool ModalOverlay::event(QEvent* ev) {
6566

6667
void ModalOverlay::setKnownBestHeight(int count, const QDateTime& blockDate)
6768
{
68-
69-
/* only update the blockheight if the headerschain-tip is not older then 30 days */
70-
int64_t now = QDateTime::currentDateTime().toTime_t();
71-
int64_t btime = blockDate.toTime_t();
72-
if (btime+3600*24*30 > now)
73-
{
74-
if (count > bestBlockHeight)
75-
bestBlockHeight = count;
69+
if (count > bestHeaderHeight) {
70+
bestHeaderHeight = count;
71+
bestHeaderDate = blockDate;
7672
}
7773
}
7874

@@ -125,11 +121,21 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
125121
ui->percentageProgress->setText(QString::number(nVerificationProgress*100, 'f', 2)+"%");
126122
ui->progressBar->setValue(nVerificationProgress*100);
127123

124+
if (!bestHeaderDate.isValid())
125+
// not syncing
126+
return;
127+
128+
// estimate the number of headers left based on nPowTargetSpacing
129+
// and check if the gui is not aware of the the best header (happens rarely)
130+
int estimateNumHeadersLeft = bestHeaderDate.secsTo(currentDate) / 600;
131+
bool hasBestHeader = bestHeaderHeight >= count;
132+
128133
// show remaining number of blocks
129-
if (bestBlockHeight > 0)
130-
ui->numberOfBlocksLeft->setText(QString::number(bestBlockHeight-count));
131-
else
134+
if (estimateNumHeadersLeft < 24 && hasBestHeader) {
135+
ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count));
136+
} else {
132137
ui->expectedTimeLeft->setText(tr("Unknown. Syncing Headers..."));
138+
}
133139
}
134140

135141
void ModalOverlay::showHide(bool hide, bool userRequested)

src/qt/modaloverlay.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public Q_SLOTS:
3535

3636
private:
3737
Ui::ModalOverlay *ui;
38-
int bestBlockHeight; //best known height (based on the headers)
38+
int bestHeaderHeight; //best known height (based on the headers)
39+
QDateTime bestHeaderDate;
3940
QVector<QPair<qint64, double> > blockProcessTime;
4041
bool layerIsVisible;
4142
bool userClosed;

0 commit comments

Comments
 (0)