Skip to content

Commit

Permalink
Merge pull request #7319
Browse files Browse the repository at this point in the history
b1a8374 [qt] Intro: Display required space (MarcoFalke)
  • Loading branch information
laanwj committed Jan 8, 2016
2 parents ff9b610 + b1a8374 commit 1320300
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/qt/intro.cpp
Expand Up @@ -15,9 +15,15 @@
#include <QSettings> #include <QSettings>
#include <QMessageBox> #include <QMessageBox>


/* Minimum free space (in bytes) needed for data directory */ #include <cmath>

static const uint64_t GB_BYTES = 1000000000LL; static const uint64_t GB_BYTES = 1000000000LL;
static const uint64_t BLOCK_CHAIN_SIZE = 20LL * GB_BYTES; /* Minimum free space (in GB) needed for data directory */
static const uint64_t BLOCK_CHAIN_SIZE = 80;
/* Minimum free space (in GB) needed for data directory when pruned; Does not include prune target */
static const uint64_t CHAIN_STATE_SIZE = 2;
/* Total required space (in GB) depending on user choice (prune, not prune) */
static uint64_t requiredSpace;


/* Check free space asynchronously to prevent hanging the UI thread. /* Check free space asynchronously to prevent hanging the UI thread.
Expand Down Expand Up @@ -112,7 +118,11 @@ Intro::Intro(QWidget *parent) :
signalled(false) signalled(false)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->sizeWarningLabel->setText(ui->sizeWarningLabel->text().arg(BLOCK_CHAIN_SIZE/GB_BYTES)); uint64_t pruneTarget = std::max<int64_t>(0, GetArg("-prune", 0));
requiredSpace = BLOCK_CHAIN_SIZE;
if (pruneTarget)
requiredSpace = CHAIN_STATE_SIZE + std::ceil(pruneTarget * 1024 * 1024.0 / GB_BYTES);
ui->sizeWarningLabel->setText(ui->sizeWarningLabel->text().arg(requiredSpace));
startThread(); startThread();
} }


Expand Down Expand Up @@ -216,9 +226,9 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
ui->freeSpace->setText(""); ui->freeSpace->setText("");
} else { } else {
QString freeString = tr("%n GB of free space available", "", bytesAvailable/GB_BYTES); QString freeString = tr("%n GB of free space available", "", bytesAvailable/GB_BYTES);
if(bytesAvailable < BLOCK_CHAIN_SIZE) if(bytesAvailable < requiredSpace * GB_BYTES)
{ {
freeString += " " + tr("(of %n GB needed)", "", BLOCK_CHAIN_SIZE/GB_BYTES); freeString += " " + tr("(of %n GB needed)", "", requiredSpace);
ui->freeSpace->setStyleSheet("QLabel { color: #800000 }"); ui->freeSpace->setStyleSheet("QLabel { color: #800000 }");
} else { } else {
ui->freeSpace->setStyleSheet(""); ui->freeSpace->setStyleSheet("");
Expand Down

0 comments on commit 1320300

Please sign in to comment.