Skip to content

Commit 987a1b5

Browse files
committed
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.
1 parent e69796c commit 987a1b5

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/common/settings.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ enum class Source {
3131
CONFIG_FILE_DEFAULT_SECTION
3232
};
3333

34+
// Json object key for the auto-generated warning comment
35+
const std::string SETTINGS_WARN_MSG_KEY{"_warning_"};
36+
3437
//! Merge settings from multiple sources in precedence order:
3538
//! Forced config > command line > read-write settings file > config file network-specific section > config file default section
3639
//!
@@ -112,6 +115,10 @@ bool ReadSettings(const fs::path& path, std::map<std::string, SettingsValue>& va
112115
break;
113116
}
114117
}
118+
119+
// Remove auto-generated warning comment from the accessible settings.
120+
values.erase(SETTINGS_WARN_MSG_KEY);
121+
115122
return errors.empty();
116123
}
117124

@@ -120,12 +127,9 @@ bool WriteSettings(const fs::path& path,
120127
std::vector<std::string>& errors)
121128
{
122129
SettingsValue out(SettingsValue::VOBJ);
123-
// Add auto-generated warning comment only if it does not exist
124-
if (!values.contains("_warning_")) {
125-
out.pushKV("_warning_", strprintf("This file is automatically generated and updated by %s. Please do not edit this file while the node "
126-
"is running, as any changes might be ignored or overwritten.",
127-
PACKAGE_NAME));
128-
}
130+
// Add auto-generated warning comment
131+
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 "
132+
"is running, as any changes might be ignored or overwritten.", PACKAGE_NAME));
129133
// Push settings values
130134
for (const auto& value : values) {
131135
out.pushKVEnd(value.first, value.second);

0 commit comments

Comments
 (0)