Skip to content

Commit

Permalink
Fix computation of download estimate.
Browse files Browse the repository at this point in the history
The previous estimate assumed the last 100 samples were 100 blocks.
  • Loading branch information
mempko committed Feb 12, 2018
1 parent 2360973 commit b317553
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/qt/modaloverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate)
// keep a vector of samples of verification progress at height
double verificationProgress = bestHeaderHeight == 0 ? 0 :
static_cast<double>(count) / static_cast<double>(bestHeaderHeight);

qint64 currentMillis = currentDate.toMSecsSinceEpoch();
blockProcessTime.push_front(qMakePair(currentMillis, verificationProgress));
blockProcessTime.push_front(qMakePair(currentMillis, count));

// show progress speed if we have more then one sample
if (blockProcessTime.size() == AVG_WINDOW_LENGTH)
Expand All @@ -111,9 +112,13 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate)

QPair<qint64, double> sample = blockProcessTime.takeLast();
timeDelta = currentMillis - sample.first;
progressDelta = verificationProgress - sample.second;
double prevVerificationProgress = bestHeaderHeight == 0 ? 0 :
static_cast<double>(sample.second) / static_cast<double>(bestHeaderHeight);

progressDelta = verificationProgress - prevVerificationProgress;

progressPerHour = progressDelta/static_cast<double>(timeDelta)*1000*3600;
remainingMSecs = (bestHeaderHeight - count) * timeDelta / AVG_WINDOW_LENGTH;
remainingMSecs = (bestHeaderHeight - count) * timeDelta / (count - sample.second);

// show progress increase per hour
ui->progressIncreasePerH->setText(QString::number(progressPerHour*100, 'f', 2)+"%");
Expand Down
2 changes: 1 addition & 1 deletion src/qt/modaloverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Q_SLOTS:
Ui::ModalOverlay *ui;
int bestHeaderHeight; //best known height (based on the headers)
QDateTime bestHeaderDate;
QVector<QPair<qint64, double> > blockProcessTime;
QVector<QPair<qint64, int> > blockProcessTime;
bool layerIsVisible;
bool userClosed;
};
Expand Down

0 comments on commit b317553

Please sign in to comment.