mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-24 05:52:08 +02:00
settings: add auto-generated warning msg for editing the file manually
Hopefully, refraining users from modifying the file unless they are certain about the potential consequences. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
|
||||
#include <common/settings.h>
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config/bitcoin-config.h>
|
||||
#endif
|
||||
|
||||
#include <tinyformat.h>
|
||||
#include <univalue.h>
|
||||
#include <util/fs.h>
|
||||
@@ -116,6 +120,13 @@ 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));
|
||||
}
|
||||
// Push settings values
|
||||
for (const auto& value : values) {
|
||||
out.pushKVEnd(value.first, value.second);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user