Skip to content

Commit b1a8374

Browse files
MarcoFalkejonasschnelli
authored andcommitted
[qt] Intro: Display required space
Required space depends on the user's choice: -prune=0 -prune=<n>
1 parent ff9b610 commit b1a8374

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/qt/intro.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@
1515
#include <QSettings>
1616
#include <QMessageBox>
1717

18-
/* Minimum free space (in bytes) needed for data directory */
18+
#include <cmath>
19+
1920
static const uint64_t GB_BYTES = 1000000000LL;
20-
static const uint64_t BLOCK_CHAIN_SIZE = 20LL * GB_BYTES;
21+
/* Minimum free space (in GB) needed for data directory */
22+
static const uint64_t BLOCK_CHAIN_SIZE = 80;
23+
/* Minimum free space (in GB) needed for data directory when pruned; Does not include prune target */
24+
static const uint64_t CHAIN_STATE_SIZE = 2;
25+
/* Total required space (in GB) depending on user choice (prune, not prune) */
26+
static uint64_t requiredSpace;
2127

2228
/* Check free space asynchronously to prevent hanging the UI thread.
2329
@@ -112,7 +118,11 @@ Intro::Intro(QWidget *parent) :
112118
signalled(false)
113119
{
114120
ui->setupUi(this);
115-
ui->sizeWarningLabel->setText(ui->sizeWarningLabel->text().arg(BLOCK_CHAIN_SIZE/GB_BYTES));
121+
uint64_t pruneTarget = std::max<int64_t>(0, GetArg("-prune", 0));
122+
requiredSpace = BLOCK_CHAIN_SIZE;
123+
if (pruneTarget)
124+
requiredSpace = CHAIN_STATE_SIZE + std::ceil(pruneTarget * 1024 * 1024.0 / GB_BYTES);
125+
ui->sizeWarningLabel->setText(ui->sizeWarningLabel->text().arg(requiredSpace));
116126
startThread();
117127
}
118128

@@ -216,9 +226,9 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
216226
ui->freeSpace->setText("");
217227
} else {
218228
QString freeString = tr("%n GB of free space available", "", bytesAvailable/GB_BYTES);
219-
if(bytesAvailable < BLOCK_CHAIN_SIZE)
229+
if(bytesAvailable < requiredSpace * GB_BYTES)
220230
{
221-
freeString += " " + tr("(of %n GB needed)", "", BLOCK_CHAIN_SIZE/GB_BYTES);
231+
freeString += " " + tr("(of %n GB needed)", "", requiredSpace);
222232
ui->freeSpace->setStyleSheet("QLabel { color: #800000 }");
223233
} else {
224234
ui->freeSpace->setStyleSheet("");

0 commit comments

Comments
 (0)