Qt/Options: When changing peerblockfilters, also set peercfilters for better downgrade compatibility

Only in bitcoin_rw.conf
This commit is contained in:
Luke Dashjr 2020-06-09 20:51:57 +00:00
parent 7dce75e5f8
commit 857523fc33
3 changed files with 7 additions and 6 deletions

View File

@ -1023,7 +1023,7 @@ void ModifyRWConfigStream(std::istream& stream_in, std::ostream& stream_out, con
}
}
void ArgsManager::ModifyRWConfigFile(const std::map<std::string, std::string>& settings_to_change)
void ArgsManager::ModifyRWConfigFile(const std::map<std::string, std::string>& settings_to_change, const bool also_settings_json)
{
LOCK(cs_args);
fs::path rwconf_path{GetRWConfigFilePath()};
@ -1050,7 +1050,7 @@ void ArgsManager::ModifyRWConfigFile(const std::map<std::string, std::string>& s
for (const auto& setting_change : settings_to_change) {
m_settings.rw_config[setting_change.first] = {setting_change.second};
}
if (!IsArgNegated("-settings")) {
if (also_settings_json && !IsArgNegated("-settings")) {
// Also save to settings.json for Core (0.21+) compatibility
for (const auto& setting_change : settings_to_change) {
m_settings.rw_settings[setting_change.first] = setting_change.second;
@ -1062,11 +1062,11 @@ void ArgsManager::ModifyRWConfigFile(const std::map<std::string, std::string>& s
}
}
void ArgsManager::ModifyRWConfigFile(const std::string& setting_to_change, const std::string& new_value)
void ArgsManager::ModifyRWConfigFile(const std::string& setting_to_change, const std::string& new_value, const bool also_settings_json)
{
std::map<std::string, std::string> settings_to_change;
settings_to_change[setting_to_change] = new_value;
ModifyRWConfigFile(settings_to_change);
ModifyRWConfigFile(settings_to_change, also_settings_json);
}
void ArgsManager::EraseRWConfigFile()

View File

@ -190,8 +190,8 @@ protected:
[[nodiscard]] bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
bool RWConfigHasPruneOption() const { return m_rwconf_had_prune_option; }
void ModifyRWConfigFile(const std::map<std::string, std::string>& settings_to_change);
void ModifyRWConfigFile(const std::string& setting_to_change, const std::string& new_value);
void ModifyRWConfigFile(const std::map<std::string, std::string>& settings_to_change, bool also_settings_json = true);
void ModifyRWConfigFile(const std::string& setting_to_change, const std::string& new_value, bool also_settings_json = true);
void EraseRWConfigFile();
/**

View File

@ -841,6 +841,7 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
bool nv = value.toBool();
if (gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS) != nv) {
gArgs.ModifyRWConfigFile("peerblockfilters", strprintf("%d", nv));
gArgs.ModifyRWConfigFile("peercfilters", strprintf("%d", nv), /*also_settings_json=*/ false); // for downgrade compatibility with Knots 0.19
gArgs.ForceSetArg("peerblockfilters", nv);
if (nv && !GetBlockFilterIndex(BlockFilterType::BASIC)) {
// TODO: When other options are possible, we need to append a list!