Changeset View
Changeset View
Standalone View
Standalone View
src/qt/modaloverlay.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | bool ModalOverlay::event(QEvent *ev) { | ||||
} | } | ||||
return QWidget::event(ev); | return QWidget::event(ev); | ||||
} | } | ||||
void ModalOverlay::setKnownBestHeight(int count, const QDateTime &blockDate) { | void ModalOverlay::setKnownBestHeight(int count, const QDateTime &blockDate) { | ||||
if (count > bestHeaderHeight) { | if (count > bestHeaderHeight) { | ||||
bestHeaderHeight = count; | bestHeaderHeight = count; | ||||
bestHeaderDate = blockDate; | bestHeaderDate = blockDate; | ||||
UpdateHeaderSyncLabel(); | |||||
} | } | ||||
} | } | ||||
void ModalOverlay::tipUpdate(int count, const QDateTime &blockDate, | void ModalOverlay::tipUpdate(int count, const QDateTime &blockDate, | ||||
double nVerificationProgress) { | double nVerificationProgress) { | ||||
QDateTime currentDate = QDateTime::currentDateTime(); | QDateTime currentDate = QDateTime::currentDateTime(); | ||||
// keep a vector of samples of verification progress at height | // keep a vector of samples of verification progress at height | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | int estimateNumHeadersLeft = bestHeaderDate.secsTo(currentDate) / | ||||
Params().GetConsensus().nPowTargetSpacing; | Params().GetConsensus().nPowTargetSpacing; | ||||
bool hasBestHeader = bestHeaderHeight >= count; | bool hasBestHeader = bestHeaderHeight >= count; | ||||
// show remaining number of blocks | // show remaining number of blocks | ||||
if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) { | if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) { | ||||
ui->numberOfBlocksLeft->setText( | ui->numberOfBlocksLeft->setText( | ||||
QString::number(bestHeaderHeight - count)); | QString::number(bestHeaderHeight - count)); | ||||
} else { | } else { | ||||
ui->numberOfBlocksLeft->setText( | UpdateHeaderSyncLabel(); | ||||
tr("Unknown. Syncing Headers (%1)...").arg(bestHeaderHeight)); | |||||
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); | ||||
if (!layerIsVisible) { | if (!layerIsVisible) { | ||||
userClosed = true; | userClosed = true; | ||||
} | } | ||||
} | } | ||||
void ModalOverlay::showHide(bool hide, bool userRequested) { | void ModalOverlay::showHide(bool hide, bool userRequested) { | ||||
Show All 24 Lines |