mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
init: settings, do not load auto-generated warning msg
The settings warning message is meant to be used only to discourage users from modifying the file manually. Therefore, there is no need to keep it in memory.
This commit is contained in:
parent
e69796c79c
commit
987a1b51ee
1 changed files with 10 additions and 6 deletions
|
@ -31,6 +31,9 @@ enum class Source {
|
|||
CONFIG_FILE_DEFAULT_SECTION
|
||||
};
|
||||
|
||||
// Json object key for the auto-generated warning comment
|
||||
const std::string SETTINGS_WARN_MSG_KEY{"_warning_"};
|
||||
|
||||
//! Merge settings from multiple sources in precedence order:
|
||||
//! Forced config > command line > read-write settings file > config file network-specific section > config file default section
|
||||
//!
|
||||
|
@ -112,6 +115,10 @@ bool ReadSettings(const fs::path& path, std::map<std::string, SettingsValue>& va
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove auto-generated warning comment from the accessible settings.
|
||||
values.erase(SETTINGS_WARN_MSG_KEY);
|
||||
|
||||
return errors.empty();
|
||||
}
|
||||
|
||||
|
@ -120,12 +127,9 @@ bool WriteSettings(const fs::path& path,
|
|||
std::vector<std::string>& errors)
|
||||
{
|
||||
SettingsValue out(SettingsValue::VOBJ);
|
||||
// Add auto-generated warning comment only if it does not exist
|
||||
if (!values.contains("_warning_")) {
|
||||
out.pushKV("_warning_", strprintf("This file is automatically generated and updated by %s. Please do not edit this file while the node "
|
||||
"is running, as any changes might be ignored or overwritten.",
|
||||
PACKAGE_NAME));
|
||||
}
|
||||
// Add auto-generated warning comment
|
||||
out.pushKV(SETTINGS_WARN_MSG_KEY, strprintf("This file is automatically generated and updated by %s. Please do not edit this file while the node "
|
||||
"is running, as any changes might be ignored or overwritten.", PACKAGE_NAME));
|
||||
// Push settings values
|
||||
for (const auto& value : values) {
|
||||
out.pushKVEnd(value.first, value.second);
|
||||
|
|
Loading…
Add table
Reference in a new issue