Skip to content

Commit 6f7395b

Browse files
committed
Merge bitcoin/bitcoin#29301: init: settings, do not load auto-generated warning msg
987a1b5 init: settings, do not load auto-generated warning msg (furszy) Pull request description: Fixes bitcoin/bitcoin#29144 (comment). 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. ACKs for top commit: achow101: ACK 987a1b5 ryanofsky: Code review ACK 987a1b5. Seems like a clean, simple fix Tree-SHA512: 3f2bdcf4b4a9cadb396dcff9b43155211eeed018527a07356970a341d139ad18edbd1a4d369377c8907b8ec1f19ee2ab8aacf85a887379e6d57a8a6db2403d51
2 parents 5a1473e + 987a1b5 commit 6f7395b

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)