Skip to content

Commit

Permalink
fix(qt): set prune dependent options correctly
Browse files Browse the repository at this point in the history
A few things to note:
1. we shouldn't rely on `bPrune` cause it can be overridden via cmd-line
2. `addOverriddenOption` is used to highlight that there are GUI options that were overridden via cmd-line and neither `-disablegovernance` nor `-txindex` override anything, we simply set them to correct values here.
3. we should do all that in `SetPruneEnabled` case that's the central point for GUI prune option logic
  • Loading branch information
kwvg authored and UdjinM6 committed Oct 27, 2024
1 parent f211bb9 commit 64b20f0
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,6 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("nPruneSize", DEFAULT_PRUNE_TARGET_GB);
SetPruneEnabled(settings.value("bPrune").toBool());

// If GUI is setting prune, then we also must set disablegovernance and txindex
if (settings.value("bPrune").toBool()) {
if (gArgs.SoftSetBoolArg("-disablegovernance", true)) {
LogPrintf("%s: parameter interaction: -prune=true -> setting -disablegovernance=true\n", __func__);
addOverriddenOption("-disablegovernance");
}
if (gArgs.SoftSetBoolArg("-txindex", false)) {
LogPrintf("%s: parameter interaction: -prune=true -> setting -txindex=false\n", __func__);
addOverriddenOption("-txindex");
}
}

if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!gArgs.SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
Expand Down Expand Up @@ -403,13 +391,21 @@ void OptionsModel::SetPruneEnabled(bool prune, bool force)
settings.setValue("bPrune", prune);
const int64_t prune_target_mib = PruneGBtoMiB(settings.value("nPruneSize").toInt());
std::string prune_val = prune ? ToString(prune_target_mib) : "0";
auto maybe_adjust_dash_options = [](){
if (gArgs.GetArg("-prune", 0) > 0) {
gArgs.SoftSetBoolArg("-disablegovernance", true);
gArgs.SoftSetBoolArg("-txindex", false);
}
};
if (force) {
gArgs.ForceSetArg("-prune", prune_val);
maybe_adjust_dash_options();
return;
}
if (!gArgs.SoftSetArg("-prune", prune_val)) {
addOverriddenOption("-prune");
}
maybe_adjust_dash_options();
}

void OptionsModel::SetPruneTargetGB(int prune_target_gb, bool force)
Expand Down

0 comments on commit 64b20f0

Please sign in to comment.