|
15 | 15 | #include <QSettings>
|
16 | 16 | #include <QMessageBox>
|
17 | 17 |
|
18 |
| -/* Minimum free space (in bytes) needed for data directory */ |
| 18 | +#include <cmath> |
| 19 | + |
19 | 20 | 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; |
21 | 27 |
|
22 | 28 | /* Check free space asynchronously to prevent hanging the UI thread.
|
23 | 29 |
|
@@ -112,7 +118,11 @@ Intro::Intro(QWidget *parent) :
|
112 | 118 | signalled(false)
|
113 | 119 | {
|
114 | 120 | 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)); |
116 | 126 | startThread();
|
117 | 127 | }
|
118 | 128 |
|
@@ -216,9 +226,9 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
|
216 | 226 | ui->freeSpace->setText("");
|
217 | 227 | } else {
|
218 | 228 | QString freeString = tr("%n GB of free space available", "", bytesAvailable/GB_BYTES);
|
219 |
| - if(bytesAvailable < BLOCK_CHAIN_SIZE) |
| 229 | + if(bytesAvailable < requiredSpace * GB_BYTES) |
220 | 230 | {
|
221 |
| - freeString += " " + tr("(of %n GB needed)", "", BLOCK_CHAIN_SIZE/GB_BYTES); |
| 231 | + freeString += " " + tr("(of %n GB needed)", "", requiredSpace); |
222 | 232 | ui->freeSpace->setStyleSheet("QLabel { color: #800000 }");
|
223 | 233 | } else {
|
224 | 234 | ui->freeSpace->setStyleSheet("");
|
|
0 commit comments