|
18 | 18 |
|
19 | 19 | #include <interfaces/node.h>
|
20 | 20 | #include <util/system.h>
|
| 21 | +#include <validation.h> |
21 | 22 |
|
22 | 23 | #include <QFileDialog>
|
23 | 24 | #include <QSettings>
|
@@ -140,17 +141,26 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
|
140 | 141 | );
|
141 | 142 | ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME));
|
142 | 143 |
|
| 144 | + const int min_prune_target_GB = std::ceil(MIN_DISK_SPACE_FOR_BLOCK_FILES / 1e9); |
| 145 | + ui->pruneGB->setRange(min_prune_target_GB, std::numeric_limits<int>::max()); |
143 | 146 | if (gArgs.GetArg("-prune", 0) > 1) { // -prune=1 means enabled, above that it's a size in MiB
|
144 | 147 | ui->prune->setChecked(true);
|
145 | 148 | ui->prune->setEnabled(false);
|
146 | 149 | }
|
147 |
| - ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(m_prune_target_gb)); |
| 150 | + ui->pruneGB->setValue(m_prune_target_gb); |
| 151 | + ui->pruneGB->setToolTip(ui->prune->toolTip()); |
| 152 | + ui->lblPruneSuffix->setToolTip(ui->prune->toolTip()); |
148 | 153 | UpdatePruneLabels(ui->prune->isChecked());
|
149 | 154 |
|
150 | 155 | connect(ui->prune, &QCheckBox::toggled, [this](bool prune_checked) {
|
151 | 156 | UpdatePruneLabels(prune_checked);
|
152 | 157 | UpdateFreeSpaceLabel();
|
153 | 158 | });
|
| 159 | + connect(ui->pruneGB, QOverload<int>::of(&QSpinBox::valueChanged), [this](int prune_GB) { |
| 160 | + m_prune_target_gb = prune_GB; |
| 161 | + UpdatePruneLabels(ui->prune->isChecked()); |
| 162 | + UpdateFreeSpaceLabel(); |
| 163 | + }); |
154 | 164 |
|
155 | 165 | startThread();
|
156 | 166 | }
|
@@ -183,7 +193,17 @@ void Intro::setDataDirectory(const QString &dataDir)
|
183 | 193 | }
|
184 | 194 | }
|
185 | 195 |
|
186 |
| -bool Intro::showIfNeeded(bool& did_show_intro, bool& prune) |
| 196 | +int64_t Intro::getPruneMiB() const |
| 197 | +{ |
| 198 | + switch (ui->prune->checkState()) { |
| 199 | + case Qt::Checked: |
| 200 | + return PruneGBtoMiB(m_prune_target_gb); |
| 201 | + case Qt::Unchecked: default: |
| 202 | + return 0; |
| 203 | + } |
| 204 | +} |
| 205 | + |
| 206 | +bool Intro::showIfNeeded(bool& did_show_intro, int64_t& prune_MiB) |
187 | 207 | {
|
188 | 208 | did_show_intro = false;
|
189 | 209 |
|
@@ -238,7 +258,7 @@ bool Intro::showIfNeeded(bool& did_show_intro, bool& prune)
|
238 | 258 | }
|
239 | 259 |
|
240 | 260 | // Additional preferences:
|
241 |
| - prune = intro.ui->prune->isChecked(); |
| 261 | + prune_MiB = intro.getPruneMiB(); |
242 | 262 |
|
243 | 263 | settings.setValue("strDataDir", dataDir);
|
244 | 264 | settings.setValue("strDataDirDefault", dataDirDefaultCurrent);
|
@@ -367,6 +387,11 @@ void Intro::UpdatePruneLabels(bool prune_checked)
|
367 | 387 | storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory.");
|
368 | 388 | }
|
369 | 389 | ui->lblExplanation3->setVisible(prune_checked);
|
| 390 | + ui->pruneGB->setEnabled(prune_checked); |
| 391 | + static constexpr uint64_t nPowTargetSpacing = 2.5 * 60; // from chainparams, which we don't have at this stage |
| 392 | + static constexpr uint32_t expected_block_data_size = 2250000; // includes undo data |
| 393 | + const uint64_t expected_backup_days = m_prune_target_gb * 1e9 / (uint64_t(expected_block_data_size) * 86400 / nPowTargetSpacing); |
| 394 | + ui->lblPruneSuffix->setText(tr("(sufficient to restore backups %n day(s) old)", "block chain pruning", expected_backup_days)); |
370 | 395 | ui->sizeWarningLabel->setText(
|
371 | 396 | tr("%1 will download and store a copy of the Dash block chain.").arg(PACKAGE_NAME) + " " +
|
372 | 397 | storageRequiresMsg.arg(m_required_space_gb) + " " +
|
|
0 commit comments