fix(qt): set prune dependent options correctly

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
This commit is contained in:
Kittywhiskers Van Gogh 2024-10-27 23:24:29 +03:00 committed by UdjinM6
parent f211bb9289
commit 64b20f0691
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9

View File

@ -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()))
@ -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)