aboutsummaryrefslogtreecommitdiff
path: root/src/qt/optionsmodel.cpp
diff options
context:
space:
mode:
authorSjors Provoost <sjors@sprovoost.nl>2019-08-24 22:31:14 +0200
committerSjors Provoost <sjors@sprovoost.nl>2019-08-24 22:36:11 +0200
commit1957103786f97135f35ababc97efa1b481865eb0 (patch)
tree35064141c2a91d0f4c2b63b6282854578ae8357c /src/qt/optionsmodel.cpp
parent1bccf6a52d7fc08d8f605cfb2edc3277ec299c72 (diff)
[gui] add explicit prune setter
This makes it possible to enable pruning after the OptionsModel has been initialized and reset.
Diffstat (limited to 'src/qt/optionsmodel.cpp')
-rw-r--r--src/qt/optionsmodel.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index f3974b1c85..d047a82475 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -92,11 +92,7 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("bPrune", false);
if (!settings.contains("nPruneSize"))
settings.setValue("nPruneSize", 2);
- // Convert prune size from GB to MiB:
- const uint64_t nPruneSizeMiB = (settings.value("nPruneSize").toInt() * GB_BYTES) >> 20;
- if (!m_node.softSetArg("-prune", settings.value("bPrune").toBool() ? std::to_string(nPruneSizeMiB) : "0")) {
- addOverriddenOption("-prune");
- }
+ SetPrune(settings.value("bPrune").toBool());
if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
@@ -240,6 +236,22 @@ static const QString GetDefaultProxyAddress()
return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT);
}
+void OptionsModel::SetPrune(bool prune, bool force)
+{
+ QSettings settings;
+ settings.setValue("bPrune", prune);
+ // Convert prune size from GB to MiB:
+ const uint64_t nPruneSizeMiB = (settings.value("nPruneSize").toInt() * GB_BYTES) >> 20;
+ std::string prune_val = prune ? std::to_string(nPruneSizeMiB) : "0";
+ if (force) {
+ m_node.forceSetArg("-prune", prune_val);
+ return;
+ }
+ if (!m_node.softSetArg("-prune", prune_val)) {
+ addOverriddenOption("-prune");
+ }
+}
+
// read QSettings values and return them
QVariant OptionsModel::data(const QModelIndex & index, int role) const
{