diff options
author | Ava Chow <github@achow101.com> | 2024-01-31 16:13:08 -0500 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2024-01-31 16:23:02 -0500 |
commit | 6f7395b3ff21228183df190f3ed1bdc3049f39e2 (patch) | |
tree | 9bf197eaf3d3099d1a14359538bb4fa04a885e85 | |
parent | 5a1473e2c0ba5e46b5c129f6a304c633239dd882 (diff) | |
parent | 987a1b51eeb72c7fcb085470817a4fe85fcc3c7c (diff) |
Merge bitcoin/bitcoin#29301: init: settings, do not load auto-generated warning msg
987a1b51eeb72c7fcb085470817a4fe85fcc3c7c init: settings, do not load auto-generated warning msg (furszy)
Pull request description:
Fixes https://github.com/bitcoin/bitcoin/pull/29144#issuecomment-1907071391.
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 987a1b51eeb72c7fcb085470817a4fe85fcc3c7c
ryanofsky:
Code review ACK 987a1b51eeb72c7fcb085470817a4fe85fcc3c7c. Seems like a clean, simple fix
Tree-SHA512: 3f2bdcf4b4a9cadb396dcff9b43155211eeed018527a07356970a341d139ad18edbd1a4d369377c8907b8ec1f19ee2ab8aacf85a887379e6d57a8a6db2403d51
-rw-r--r-- | src/common/settings.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 913ad6d76a..db1001111a 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -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); |