[Qt] Add option to pause/resume block downloads #9502
Open
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1e165bf
Add fAutoRequestBlocks to disabled/enable the verification progress
jonasschnelli b30c8a1
[Qt] update header-syncing progress when not processing a block
jonasschnelli 5702c49
[Qt] Add option to pause/resume block downloads
jonasschnelli 0ac2217
Rename autorequest blocks methods
jonasschnelli f7e8ef4
Add setter/getter for fAutoRequestBlocks
jonasschnelli b072636
Show block in flight
jonasschnelli 17e1dab
Show special info when autodownload is disabled but blocks are in flight
jonasschnelli f1b057f
Disable "pause downloading blocks" when we can fetch blocks directly
jonasschnelli
Jump to file or symbol
Failed to load files and symbols.
| @@ -8,6 +8,7 @@ | ||
| #include "guiutil.h" | ||
| #include "chainparams.h" | ||
| +#include "net_processing.h" | ||
| #include <QResizeEvent> | ||
| #include <QPropertyAnimation> | ||
| @@ -18,10 +19,12 @@ ui(new Ui::ModalOverlay), | ||
| bestHeaderHeight(0), | ||
| bestHeaderDate(QDateTime()), | ||
| layerIsVisible(false), | ||
| -userClosed(false) | ||
| +userClosed(false), | ||
| +verificationPauseActive(false) | ||
| { | ||
| ui->setupUi(this); | ||
| connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(closeClicked())); | ||
| + connect(ui->pauseResumeVerification, SIGNAL(clicked()), this, SLOT(pauseClicked())); | ||
| if (parent) { | ||
| parent->installEventFilter(this); | ||
| raise(); | ||
| @@ -71,6 +74,7 @@ void ModalOverlay::setKnownBestHeight(int count, const QDateTime& blockDate) | ||
| if (count > bestHeaderHeight) { | ||
| bestHeaderHeight = count; | ||
| bestHeaderDate = blockDate; | ||
| + eventuallyShowHeaderSyncing(count); | ||
| } | ||
| } | ||
| @@ -125,15 +129,30 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri | ||
| // not syncing | ||
| return; | ||
| + // show remaining number of blocks | ||
| + ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count)); | ||
| + | ||
| + // show already requested blocks (in total) | ||
| + ui->numberBlocksRequested->setText(QString::number(getAmountOfBlocksInFlight())); | ||
| + eventuallyShowHeaderSyncing(count); | ||
| + updatePauseState(verificationPauseActive); | ||
| + | ||
| + // disable pause button when we we can fetch directly | ||
| + // avoid using the core-layer's existing CanFetchDirectly() | ||
| + bool canFetchDirecly = (blockDate.toTime_t() > GetAdjustedTime() - Params().GetConsensus().nPowTargetSpacing * 20); | ||
| + ui->pauseResumeVerification->setEnabled(!canFetchDirecly); | ||
| + ui->infoLabel->setVisible(!canFetchDirecly); | ||
| +} | ||
| + | ||
| +void ModalOverlay::eventuallyShowHeaderSyncing(int count) | ||
| +{ | ||
| // estimate the number of headers left based on nPowTargetSpacing | ||
| // and check if the gui is not aware of the best header (happens rarely) | ||
| - int estimateNumHeadersLeft = bestHeaderDate.secsTo(currentDate) / Params().GetConsensus().nPowTargetSpacing; | ||
| + int estimateNumHeadersLeft = bestHeaderDate.secsTo(QDateTime::currentDateTime()) / Params().GetConsensus().nPowTargetSpacing; | ||
| bool hasBestHeader = bestHeaderHeight >= count; | ||
| - // show remaining number of blocks | ||
| - if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) { | ||
| - ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count)); | ||
| - } else { | ||
| + // show headers-syncing progress if we still sync headers | ||
| + if (estimateNumHeadersLeft >= HEADER_HEIGHT_DELTA_SYNC || !hasBestHeader) { | ||
| ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1)...").arg(bestHeaderHeight)); | ||
| ui->expectedTimeLeft->setText(tr("Unknown...")); | ||
| } | ||
| @@ -170,3 +189,21 @@ void ModalOverlay::closeClicked() | ||
| showHide(true); | ||
| userClosed = true; | ||
| } | ||
| + | ||
| +void ModalOverlay::pauseClicked() | ||
| +{ | ||
| + Q_EMIT requestVerificationPauseOrResume(); | ||
| +} | ||
| + | ||
| +void ModalOverlay::setPauseResumeState(bool pauseActive) | ||
| +{ | ||
| + verificationPauseActive = pauseActive; | ||
| + updatePauseState(pauseActive); | ||
| +} | ||
| + | ||
| +void ModalOverlay::updatePauseState(bool pauseActive) | ||
| +{ | ||
| + ui->labelNumberBlocksRequested->setText((pauseActive ? "Finish downloading blocks": "Blocks requested from peers")); | ||
promag
Contributor
|
||
| + ui->pauseResumeVerification->setText((pauseActive ? "Resume downloading blocks ": "Pause downloading blocks")); | ||
| + ui->infoLabel->setText((pauseActive && getAmountOfBlocksInFlight() > 0 ? "Wait to finish current downloads...": "")); | ||
promag
Contributor
|
||
| +} | ||
Oops, something went wrong.
Nit, can't comment there, but remove
leftMarginabove to be consistent.