aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2015-12-29 15:38:38 +0100
committerJonas Schnelli <dev@jonasschnelli.ch>2016-01-08 11:22:08 +0100
commitb1a8374aaa82e08de8ac9353e76be3cdf43cd3d5 (patch)
tree32ba6f26e43e7f0a19a76d7fb93a90a9c097d0b6 /src
parentff9b610026067755b1d766c13a212734d96757ea (diff)
downloadbitcoin-b1a8374aaa82e08de8ac9353e76be3cdf43cd3d5.tar.xz
[qt] Intro: Display required space
Required space depends on the user's choice: -prune=0 -prune=<n>
Diffstat (limited to 'src')
-rw-r--r--src/qt/intro.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp
index e0b84ba13f..f324c6dc5a 100644
--- a/src/qt/intro.cpp
+++ b/src/qt/intro.cpp
@@ -15,9 +15,15 @@
#include <QSettings>
#include <QMessageBox>
-/* Minimum free space (in bytes) needed for data directory */
+#include <cmath>
+
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.
@@ -112,7 +118,11 @@ Intro::Intro(QWidget *parent) :
signalled(false)
{
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();
}
@@ -216,9 +226,9 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
ui->freeSpace->setText("");
} else {
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 }");
} else {
ui->freeSpace->setStyleSheet("");