[qt] OptionsDialog: add prune setting
This commit is contained in:
parent
3b84ebb5bc
commit
cbede7dbfd
6 changed files with 118 additions and 2 deletions
|
@ -56,6 +56,11 @@ frequently tested on them.
|
|||
Notable changes
|
||||
===============
|
||||
|
||||
GUI changes
|
||||
-----------
|
||||
|
||||
- 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.
|
||||
|
||||
RPC changes
|
||||
------------
|
||||
|
||||
|
|
|
@ -37,6 +37,69 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_0_Main">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Main_Prune">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="prune">
|
||||
<property name="toolTip">
|
||||
<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>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Prune &block storage to</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="pruneSize"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="pruneSizeUnitLabel">
|
||||
<property name="text">
|
||||
<string>GB</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_Main_Prune">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="pruneWarning">
|
||||
<property name="text">
|
||||
<string>Reverting this setting requires re-downloading the entire blockchain.</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2_Main">
|
||||
<item>
|
||||
|
@ -81,7 +144,7 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3_Main">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Main_VerifyLabel">
|
||||
<item>
|
||||
<widget class="QLabel" name="threadsScriptVerifLabel">
|
||||
<property name="text">
|
||||
|
@ -103,7 +166,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3_Main">
|
||||
<spacer name="horizontalSpacer_Main_Threads">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
|
|
@ -36,8 +36,17 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
|||
/* Main elements init */
|
||||
ui->databaseCache->setMinimum(nMinDbCache);
|
||||
ui->databaseCache->setMaximum(nMaxDbCache);
|
||||
static const uint64_t GiB = 1024 * 1024 * 1024;
|
||||
static const uint64_t nMinDiskSpace = MIN_DISK_SPACE_FOR_BLOCK_FILES / GiB +
|
||||
(MIN_DISK_SPACE_FOR_BLOCK_FILES % GiB) ? 1 : 0;
|
||||
ui->pruneSize->setMinimum(nMinDiskSpace);
|
||||
ui->threadsScriptVerif->setMinimum(-GetNumCores());
|
||||
ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
|
||||
ui->pruneWarning->setVisible(false);
|
||||
ui->pruneWarning->setStyleSheet("QLabel { color: red; }");
|
||||
|
||||
ui->pruneSize->setEnabled(false);
|
||||
connect(ui->prune, SIGNAL(toggled(bool)), ui->pruneSize, SLOT(setEnabled(bool)));
|
||||
|
||||
/* Network elements init */
|
||||
#ifndef USE_UPNP
|
||||
|
@ -157,6 +166,9 @@ void OptionsDialog::setModel(OptionsModel *_model)
|
|||
/* warn when one of the following settings changes by user action (placed here so init via mapper doesn't trigger them) */
|
||||
|
||||
/* Main */
|
||||
connect(ui->prune, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning()));
|
||||
connect(ui->prune, SIGNAL(clicked(bool)), this, SLOT(togglePruneWarning(bool)));
|
||||
connect(ui->pruneSize, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
|
||||
connect(ui->databaseCache, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
|
||||
connect(ui->threadsScriptVerif, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
|
||||
/* Wallet */
|
||||
|
@ -176,6 +188,8 @@ void OptionsDialog::setMapper()
|
|||
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
|
||||
mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif);
|
||||
mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache);
|
||||
mapper->addMapping(ui->prune, OptionsModel::Prune);
|
||||
mapper->addMapping(ui->pruneSize, OptionsModel::PruneSize);
|
||||
|
||||
/* Wallet */
|
||||
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
|
||||
|
@ -266,6 +280,11 @@ void OptionsDialog::on_hideTrayIcon_stateChanged(int fState)
|
|||
}
|
||||
}
|
||||
|
||||
void OptionsDialog::togglePruneWarning(bool enabled)
|
||||
{
|
||||
ui->pruneWarning->setVisible(!ui->pruneWarning->isVisible());
|
||||
}
|
||||
|
||||
void OptionsDialog::showRestartWarning(bool fPersistent)
|
||||
{
|
||||
ui->statusLabel->setStyleSheet("QLabel { color: red; }");
|
||||
|
|
|
@ -53,6 +53,7 @@ private Q_SLOTS:
|
|||
|
||||
void on_hideTrayIcon_stateChanged(int fState);
|
||||
|
||||
void togglePruneWarning(bool enabled);
|
||||
void showRestartWarning(bool fPersistent = false);
|
||||
void clearStatusLabel();
|
||||
void updateProxyValidationState();
|
||||
|
|
|
@ -88,6 +88,16 @@ void OptionsModel::Init(bool resetSettings)
|
|||
// by command-line and show this in the UI.
|
||||
|
||||
// Main
|
||||
if (!settings.contains("bPrune"))
|
||||
settings.setValue("bPrune", false);
|
||||
if (!settings.contains("nPruneSize"))
|
||||
settings.setValue("nPruneSize", 2);
|
||||
// Convert prune size to MB:
|
||||
const uint64_t nPruneSizeMB = settings.value("nPruneSize").toInt() * 1000;
|
||||
if (!m_node.softSetArg("-prune", settings.value("bPrune").toBool() ? std::to_string(nPruneSizeMB) : "0")) {
|
||||
addOverriddenOption("-prune");
|
||||
}
|
||||
|
||||
if (!settings.contains("nDatabaseCache"))
|
||||
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
|
||||
if (!m_node.softSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
|
||||
|
@ -281,6 +291,10 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
|||
return settings.value("language");
|
||||
case CoinControlFeatures:
|
||||
return fCoinControlFeatures;
|
||||
case Prune:
|
||||
return settings.value("bPrune");
|
||||
case PruneSize:
|
||||
return settings.value("nPruneSize");
|
||||
case DatabaseCache:
|
||||
return settings.value("nDatabaseCache");
|
||||
case ThreadsScriptVerif:
|
||||
|
@ -405,6 +419,18 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
|||
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
|
||||
Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures);
|
||||
break;
|
||||
case Prune:
|
||||
if (settings.value("bPrune") != value) {
|
||||
settings.setValue("bPrune", value);
|
||||
setRestartRequired(true);
|
||||
}
|
||||
break;
|
||||
case PruneSize:
|
||||
if (settings.value("nPruneSize") != value) {
|
||||
settings.setValue("nPruneSize", value);
|
||||
setRestartRequired(true);
|
||||
}
|
||||
break;
|
||||
case DatabaseCache:
|
||||
if (settings.value("nDatabaseCache") != value) {
|
||||
settings.setValue("nDatabaseCache", value);
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
Language, // QString
|
||||
CoinControlFeatures, // bool
|
||||
ThreadsScriptVerif, // int
|
||||
Prune, // bool
|
||||
PruneSize, // int
|
||||
DatabaseCache, // int
|
||||
SpendZeroConfChange, // bool
|
||||
Listen, // bool
|
||||
|
|
Loading…
Add table
Reference in a new issue