Skip to content

Commit 6e249e4

Browse files
committed
Merge #13043: [qt] OptionsDialog: add prune setting
cbede7d [qt] OptionsDialog: add prune setting (Sjors Provoost) Pull request description: The default suggested value is 2 GB. Minimum is 1 GB (550 MB rounded up). When the user toggles this setting, a strong warning appears that undoing requires re-downloading the chain: <img width="478" alt="schermafbeelding 2018-05-15 om 12 35 24" src="https://user-images.githubusercontent.com/10217/40051858-7939cc20-583c-11e8-9120-327a75376732.png"> Tooltip points out that actual disk usage can be higher. It's a bit vague on the "advanced features", because I'm assuming anyone who needs to use `-rescan` and `-txindex` will read the documentation, and a more detailed text would needlessly confuse everyone else. <img width="450" alt="schermafbeelding 2018-05-15 om 12 33 51" src="https://user-images.githubusercontent.com/10217/40051791-49d6156a-583c-11e8-97b9-7de6dfd8c481.png"> The UI uses gigabytes for readability and easy of use. There is also no manual pruning UI (`prune=1`). The user will have to use `bitcoin.conf` for those things. Fixes #6461. When combined with #13029 the user, after pruning their node, can safely reset settings and/or use bitcoind without having to edit `bitcoin.conf`. However I don't think that's an essential prerequisite. Tree-SHA512: e17aff276d7235fbd40796adb6431d430620788a753ee13bc064abd35d2edc4280a3d3cddc18e42b4e00edff13ed18fd4f2a966c6f0b43b689afd13673e0c4bf
2 parents 56f6936 + cbede7d commit 6e249e4

File tree

6 files changed

+118
-2
lines changed

6 files changed

+118
-2
lines changed

doc/release-notes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ frequently tested on them.
5656
Notable changes
5757
===============
5858

59+
GUI changes
60+
-----------
61+
62+
- Block storage can be limited under Preferences, in the Main tab. Undoing this setting requires downloading the full blockchain again. This mode is incompatible with -txindex and -rescan.
63+
5964
RPC changes
6065
------------
6166

src/qt/forms/optionsdialog.ui

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,69 @@
3737
</property>
3838
</widget>
3939
</item>
40+
<item>
41+
<spacer name="horizontalSpacer_0_Main">
42+
<property name="orientation">
43+
<enum>Qt::Horizontal</enum>
44+
</property>
45+
<property name="sizeHint" stdset="0">
46+
<size>
47+
<width>40</width>
48+
<height>5</height>
49+
</size>
50+
</property>
51+
</spacer>
52+
</item>
53+
<item>
54+
<layout class="QHBoxLayout" name="horizontalLayout_Main_Prune">
55+
<item>
56+
<widget class="QCheckBox" name="prune">
57+
<property name="toolTip">
58+
<string>Disables some advanced features but all blocks will still be fully validated. Reverting this setting requires re-downloading the entire blockchain. Actual disk usage may be somewhat higher.</string>
59+
</property>
60+
<property name="text">
61+
<string>Prune &amp;block storage to</string>
62+
</property>
63+
</widget>
64+
</item>
65+
<item>
66+
<widget class="QSpinBox" name="pruneSize"/>
67+
</item>
68+
<item>
69+
<widget class="QLabel" name="pruneSizeUnitLabel">
70+
<property name="text">
71+
<string>GB</string>
72+
</property>
73+
<property name="textFormat">
74+
<enum>Qt::PlainText</enum>
75+
</property>
76+
</widget>
77+
</item>
78+
<item>
79+
<spacer name="horizontalSpacer_Main_Prune">
80+
<property name="orientation">
81+
<enum>Qt::Horizontal</enum>
82+
</property>
83+
<property name="sizeHint" stdset="0">
84+
<size>
85+
<width>40</width>
86+
<height>20</height>
87+
</size>
88+
</property>
89+
</spacer>
90+
</item>
91+
</layout>
92+
</item>
93+
<item>
94+
<widget class="QLabel" name="pruneWarning">
95+
<property name="text">
96+
<string>Reverting this setting requires re-downloading the entire blockchain.</string>
97+
</property>
98+
<property name="textFormat">
99+
<enum>Qt::PlainText</enum>
100+
</property>
101+
</widget>
102+
</item>
40103
<item>
41104
<layout class="QHBoxLayout" name="horizontalLayout_2_Main">
42105
<item>
@@ -81,7 +144,7 @@
81144
</layout>
82145
</item>
83146
<item>
84-
<layout class="QHBoxLayout" name="horizontalLayout_3_Main">
147+
<layout class="QHBoxLayout" name="horizontalLayout_Main_VerifyLabel">
85148
<item>
86149
<widget class="QLabel" name="threadsScriptVerifLabel">
87150
<property name="text">
@@ -103,7 +166,7 @@
103166
</widget>
104167
</item>
105168
<item>
106-
<spacer name="horizontalSpacer_3_Main">
169+
<spacer name="horizontalSpacer_Main_Threads">
107170
<property name="orientation">
108171
<enum>Qt::Horizontal</enum>
109172
</property>

src/qt/optionsdialog.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
3636
/* Main elements init */
3737
ui->databaseCache->setMinimum(nMinDbCache);
3838
ui->databaseCache->setMaximum(nMaxDbCache);
39+
static const uint64_t GiB = 1024 * 1024 * 1024;
40+
static const uint64_t nMinDiskSpace = MIN_DISK_SPACE_FOR_BLOCK_FILES / GiB +
41+
(MIN_DISK_SPACE_FOR_BLOCK_FILES % GiB) ? 1 : 0;
42+
ui->pruneSize->setMinimum(nMinDiskSpace);
3943
ui->threadsScriptVerif->setMinimum(-GetNumCores());
4044
ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
45+
ui->pruneWarning->setVisible(false);
46+
ui->pruneWarning->setStyleSheet("QLabel { color: red; }");
47+
48+
ui->pruneSize->setEnabled(false);
49+
connect(ui->prune, SIGNAL(toggled(bool)), ui->pruneSize, SLOT(setEnabled(bool)));
4150

4251
/* Network elements init */
4352
#ifndef USE_UPNP
@@ -157,6 +166,9 @@ void OptionsDialog::setModel(OptionsModel *_model)
157166
/* warn when one of the following settings changes by user action (placed here so init via mapper doesn't trigger them) */
158167

159168
/* Main */
169+
connect(ui->prune, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning()));
170+
connect(ui->prune, SIGNAL(clicked(bool)), this, SLOT(togglePruneWarning(bool)));
171+
connect(ui->pruneSize, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
160172
connect(ui->databaseCache, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
161173
connect(ui->threadsScriptVerif, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
162174
/* Wallet */
@@ -176,6 +188,8 @@ void OptionsDialog::setMapper()
176188
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
177189
mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif);
178190
mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache);
191+
mapper->addMapping(ui->prune, OptionsModel::Prune);
192+
mapper->addMapping(ui->pruneSize, OptionsModel::PruneSize);
179193

180194
/* Wallet */
181195
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
@@ -266,6 +280,11 @@ void OptionsDialog::on_hideTrayIcon_stateChanged(int fState)
266280
}
267281
}
268282

283+
void OptionsDialog::togglePruneWarning(bool enabled)
284+
{
285+
ui->pruneWarning->setVisible(!ui->pruneWarning->isVisible());
286+
}
287+
269288
void OptionsDialog::showRestartWarning(bool fPersistent)
270289
{
271290
ui->statusLabel->setStyleSheet("QLabel { color: red; }");

src/qt/optionsdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private Q_SLOTS:
5353

5454
void on_hideTrayIcon_stateChanged(int fState);
5555

56+
void togglePruneWarning(bool enabled);
5657
void showRestartWarning(bool fPersistent = false);
5758
void clearStatusLabel();
5859
void updateProxyValidationState();

src/qt/optionsmodel.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ void OptionsModel::Init(bool resetSettings)
8888
// by command-line and show this in the UI.
8989

9090
// Main
91+
if (!settings.contains("bPrune"))
92+
settings.setValue("bPrune", false);
93+
if (!settings.contains("nPruneSize"))
94+
settings.setValue("nPruneSize", 2);
95+
// Convert prune size to MB:
96+
const uint64_t nPruneSizeMB = settings.value("nPruneSize").toInt() * 1000;
97+
if (!m_node.softSetArg("-prune", settings.value("bPrune").toBool() ? std::to_string(nPruneSizeMB) : "0")) {
98+
addOverriddenOption("-prune");
99+
}
100+
91101
if (!settings.contains("nDatabaseCache"))
92102
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
93103
if (!m_node.softSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
@@ -281,6 +291,10 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
281291
return settings.value("language");
282292
case CoinControlFeatures:
283293
return fCoinControlFeatures;
294+
case Prune:
295+
return settings.value("bPrune");
296+
case PruneSize:
297+
return settings.value("nPruneSize");
284298
case DatabaseCache:
285299
return settings.value("nDatabaseCache");
286300
case ThreadsScriptVerif:
@@ -405,6 +419,18 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
405419
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
406420
Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures);
407421
break;
422+
case Prune:
423+
if (settings.value("bPrune") != value) {
424+
settings.setValue("bPrune", value);
425+
setRestartRequired(true);
426+
}
427+
break;
428+
case PruneSize:
429+
if (settings.value("nPruneSize") != value) {
430+
settings.setValue("nPruneSize", value);
431+
setRestartRequired(true);
432+
}
433+
break;
408434
case DatabaseCache:
409435
if (settings.value("nDatabaseCache") != value) {
410436
settings.setValue("nDatabaseCache", value);

src/qt/optionsmodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class OptionsModel : public QAbstractListModel
5050
Language, // QString
5151
CoinControlFeatures, // bool
5252
ThreadsScriptVerif, // int
53+
Prune, // bool
54+
PruneSize, // int
5355
DatabaseCache, // int
5456
SpendZeroConfChange, // bool
5557
Listen, // bool

0 commit comments

Comments
 (0)