diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2019-04-29 15:29:00 -0400 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2022-05-26 11:05:10 -0400 |
commit | a7ef6d5975a5f40b90b2709b32a00647bd2bd5a3 (patch) | |
tree | 3cc89ef7c769886d9a61dc30c7dcbc34d405dfad /src/qt | |
parent | 284f339de68905131331f7fdb4c0b945c9a1b8cd (diff) | |
download | bitcoin-a7ef6d5975a5f40b90b2709b32a00647bd2bd5a3.tar.xz |
Migrate -par setting from QSettings to settings.json
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/optionsmodel.cpp | 20 | ||||
-rw-r--r-- | src/qt/test/optiontests.cpp | 5 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 6f61afed54..b42dbf40df 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -37,6 +37,7 @@ static const char* SettingName(OptionsModel::OptionID option) { switch (option) { case OptionsModel::DatabaseCache: return "dbcache"; + case OptionsModel::ThreadsScriptVerif: return "par"; default: throw std::logic_error(strprintf("GUI option %i has no corresponding node setting.", option)); } } @@ -44,7 +45,9 @@ static const char* SettingName(OptionsModel::OptionID option) /** Call node.updateRwSetting() with Bitcoin 22.x workaround. */ static void UpdateRwSetting(interfaces::Node& node, OptionsModel::OptionID option, const util::SettingsValue& value) { - if (value.isNum() && option == OptionsModel::DatabaseCache) { + if (value.isNum() && + (option == OptionsModel::DatabaseCache || + option == OptionsModel::ThreadsScriptVerif)) { // Write certain old settings as strings, even though they are numbers, // because Bitcoin 22.x releases try to read these specific settings as // strings in addOverriddenOption() calls at startup, triggering @@ -122,7 +125,7 @@ bool OptionsModel::Init(bilingual_str& error) // These are shared with the core or have a command-line parameter // and we want command-line parameters to overwrite the GUI settings. - for (OptionID option : {DatabaseCache}) { + for (OptionID option : {DatabaseCache, ThreadsScriptVerif}) { std::string setting = SettingName(option); if (node().isSettingIgnored(setting)) addOverriddenOption("-" + setting); try { @@ -147,12 +150,6 @@ bool OptionsModel::Init(bilingual_str& error) if (!settings.contains("nPruneSize")) settings.setValue("nPruneSize", DEFAULT_PRUNE_TARGET_GB); SetPruneEnabled(settings.value("bPrune").toBool()); - - if (!settings.contains("nThreadsScriptVerif")) - settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS); - if (!gArgs.SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString())) - addOverriddenOption("-par"); - if (!settings.contains("strDataDir")) settings.setValue("strDataDir", GUIUtil::getDefaultDataDirectory()); @@ -458,7 +455,7 @@ QVariant OptionsModel::getOption(OptionID option) const case DatabaseCache: return qlonglong(SettingToInt(setting(), nDefaultDbCache)); case ThreadsScriptVerif: - return settings.value("nThreadsScriptVerif"); + return qlonglong(SettingToInt(setting(), DEFAULT_SCRIPTCHECK_THREADS)); case Listen: return settings.value("fListen"); case Server: @@ -619,8 +616,8 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value) } break; case ThreadsScriptVerif: - if (settings.value("nThreadsScriptVerif") != value) { - settings.setValue("nThreadsScriptVerif", value); + if (changed()) { + update(static_cast<int64_t>(value.toLongLong())); setRestartRequired(true); } break; @@ -705,4 +702,5 @@ void OptionsModel::checkAndMigrate() }; migrate_setting(DatabaseCache, "nDatabaseCache"); + migrate_setting(ThreadsScriptVerif, "nThreadsScriptVerif"); } diff --git a/src/qt/test/optiontests.cpp b/src/qt/test/optiontests.cpp index fb8b78f66e..fa3fe031ec 100644 --- a/src/qt/test/optiontests.cpp +++ b/src/qt/test/optiontests.cpp @@ -33,6 +33,7 @@ void OptionTests::migrateSettings() // settings.json QSettings settings; settings.setValue("nDatabaseCache", 600); + settings.setValue("nThreadsScriptVerif", 12); settings.sync(); @@ -40,10 +41,12 @@ void OptionTests::migrateSettings() bilingual_str error; QVERIFY(options.Init(error)); QVERIFY(!settings.contains("nDatabaseCache")); + QVERIFY(!settings.contains("nThreadsScriptVerif")); std::ifstream file(gArgs.GetDataDirNet() / "settings.json"); QCOMPARE(std::string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()).c_str(), "{\n" - " \"dbcache\": \"600\"\n" + " \"dbcache\": \"600\",\n" + " \"par\": \"12\"\n" "}\n"); } |