v29.4-roots.3 · Commit 2: [PATCH 02/30] runtime: preserve shared operator controls
src/common/args.h
Before: src/common/args.h · After: src/common/args.h
File metadata
index 8d9daf5f65d8698dce49d11fa12da0b80e9c5d77..9fa89c972ba17d60a1697b61f892c883358a2c73 100644
Download original patch · Release notes
Diff rows 1–88 of 88. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
src/common/args.h
CHANGED
|
@@ -25,6 +25,7 @@ class ArgsManager;
|
|
| 25 |
|
| 26 |
extern const char * const BITCOIN_CONF_FILENAME;
|
| 27 |
extern const char * const BITCOIN_SETTINGS_FILENAME;
|
|
|
|
| 28 |
|
| 29 |
// Return true if -datadir option points to a valid directory or is not specified.
|
| 30 |
bool CheckDataDirOption(const ArgsManager& args);
|
|
@@ -65,6 +66,7 @@ enum class OptionsCategory {
|
|
| 65 |
REGISTER_COMMANDS,
|
| 66 |
CLI_COMMANDS,
|
| 67 |
IPC,
|
|
|
|
| 68 |
|
| 69 |
HIDDEN // Always the last option to avoid printing these in the help
|
| 70 |
};
|
|
@@ -92,9 +94,13 @@ std::optional<std::string> SettingToString(const common::SettingsValue&);
|
|
| 92 |
int64_t SettingToInt(const common::SettingsValue&, int64_t);
|
| 93 |
std::optional<int64_t> SettingToInt(const common::SettingsValue&);
|
| 94 |
|
|
|
|
|
|
|
| 95 |
bool SettingToBool(const common::SettingsValue&, bool);
|
| 96 |
std::optional<bool> SettingToBool(const common::SettingsValue&);
|
| 97 |
|
|
|
|
|
|
|
| 98 |
class ArgsManager
|
| 99 |
{
|
| 100 |
public:
|
|
@@ -140,11 +146,13 @@ protected:
|
|
| 140 |
bool m_accept_any_command GUARDED_BY(cs_args){true};
|
| 141 |
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
|
| 142 |
std::optional<fs::path> m_config_path GUARDED_BY(cs_args);
|
|
|
|
|
|
|
| 143 |
mutable fs::path m_cached_blocks_path GUARDED_BY(cs_args);
|
| 144 |
mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
|
| 145 |
mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
|
| 146 |
|
| 147 |
-
[[nodiscard]] bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false);
|
| 148 |
|
| 149 |
/**
|
| 150 |
* Returns true if settings values from the default section should be used,
|
|
@@ -183,8 +191,14 @@ protected:
|
|
| 183 |
*/
|
| 184 |
fs::path GetConfigFilePath() const;
|
| 185 |
void SetConfigFilePath(fs::path);
|
|
|
|
| 186 |
[[nodiscard]] bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
|
| 187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
/**
|
| 189 |
* Log warnings for options in m_section_only_args when
|
| 190 |
* they are specified in the default section but not overridden
|
|
@@ -295,6 +309,15 @@ protected:
|
|
| 295 |
int64_t GetIntArg(const std::string& strArg, int64_t nDefault) const;
|
| 296 |
std::optional<int64_t> GetIntArg(const std::string& strArg) const;
|
| 297 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
/**
|
| 299 |
* Return boolean argument or default value
|
| 300 |
*
|
|
@@ -325,7 +348,9 @@ protected:
|
|
| 325 |
|
| 326 |
// Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
|
| 327 |
// been set. Also called directly in testing.
|
| 328 |
-
void ForceSetArg(const std::string& strArg, const std::string& strValue);
|
|
|
|
|
|
|
| 329 |
|
| 330 |
/**
|
| 331 |
* Returns the appropriate chain type from the program arguments.
|
|
@@ -354,7 +379,7 @@ protected:
|
|
| 354 |
/**
|
| 355 |
* Add many hidden arguments
|
| 356 |
*/
|
| 357 |
-
void AddHiddenArgs(const std::vector<std::string>& args);
|
| 358 |
|
| 359 |
/**
|
| 360 |
* Clear available arguments
|
|
|
|
| 25 |
|
| 26 |
extern const char * const BITCOIN_CONF_FILENAME;
|
| 27 |
extern const char * const BITCOIN_SETTINGS_FILENAME;
|
| 28 |
+
extern const char * const BITCOIN_RW_CONF_FILENAME;
|
| 29 |
|
| 30 |
// Return true if -datadir option points to a valid directory or is not specified.
|
| 31 |
bool CheckDataDirOption(const ArgsManager& args);
|
|
|
|
| 66 |
REGISTER_COMMANDS,
|
| 67 |
CLI_COMMANDS,
|
| 68 |
IPC,
|
| 69 |
+
STATS,
|
| 70 |
|
| 71 |
HIDDEN // Always the last option to avoid printing these in the help
|
| 72 |
};
|
|
|
|
| 94 |
int64_t SettingToInt(const common::SettingsValue&, int64_t);
|
| 95 |
std::optional<int64_t> SettingToInt(const common::SettingsValue&);
|
| 96 |
|
| 97 |
+
std::optional<int64_t> SettingToFixedPoint(const common::SettingsValue&, int decimals);
|
| 98 |
+
|
| 99 |
bool SettingToBool(const common::SettingsValue&, bool);
|
| 100 |
std::optional<bool> SettingToBool(const common::SettingsValue&);
|
| 101 |
|
| 102 |
+
void ModifyRWConfigStream(std::istream& stream_in, std::ostream& stream_out, const std::map<std::string, std::string>& settings_to_change);
|
| 103 |
+
|
| 104 |
class ArgsManager
|
| 105 |
{
|
| 106 |
public:
|
|
|
|
| 146 |
bool m_accept_any_command GUARDED_BY(cs_args){true};
|
| 147 |
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
|
| 148 |
std::optional<fs::path> m_config_path GUARDED_BY(cs_args);
|
| 149 |
+
std::optional<fs::path> m_rwconf_path GUARDED_BY(cs_args);
|
| 150 |
+
bool m_rwconf_had_prune_option{false};
|
| 151 |
mutable fs::path m_cached_blocks_path GUARDED_BY(cs_args);
|
| 152 |
mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
|
| 153 |
mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
|
| 154 |
|
| 155 |
+
[[nodiscard]] bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false, std::map<std::string, std::vector<common::SettingsValue>>* settings_target = nullptr);
|
| 156 |
|
| 157 |
/**
|
| 158 |
* Returns true if settings values from the default section should be used,
|
|
|
|
| 191 |
*/
|
| 192 |
fs::path GetConfigFilePath() const;
|
| 193 |
void SetConfigFilePath(fs::path);
|
| 194 |
+
fs::path GetRWConfigFilePath() const;
|
| 195 |
[[nodiscard]] bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
|
| 196 |
|
| 197 |
+
bool RWConfigHasPruneOption() const { return m_rwconf_had_prune_option; }
|
| 198 |
+
void ModifyRWConfigFile(const std::map<std::string, std::string>& settings_to_change, bool also_settings_json = true);
|
| 199 |
+
void ModifyRWConfigFile(const std::string& setting_to_change, const std::string& new_value, bool also_settings_json = true);
|
| 200 |
+
void EraseRWConfigFile();
|
| 201 |
+
|
| 202 |
/**
|
| 203 |
* Log warnings for options in m_section_only_args when
|
| 204 |
* they are specified in the default section but not overridden
|
|
|
|
| 309 |
int64_t GetIntArg(const std::string& strArg, int64_t nDefault) const;
|
| 310 |
std::optional<int64_t> GetIntArg(const std::string& strArg) const;
|
| 311 |
|
| 312 |
+
/**
|
| 313 |
+
* Return fixed-point argument
|
| 314 |
+
*
|
| 315 |
+
* @param arg Argument to get (e.g. "-foo")
|
| 316 |
+
* @param decimals Number of fractional decimal digits to accept
|
| 317 |
+
* @return Command-line argument (0 if invalid number) multiplied by 10**decimals
|
| 318 |
+
*/
|
| 319 |
+
std::optional<int64_t> GetFixedPointArg(const std::string& arg, int decimals) const;
|
| 320 |
+
|
| 321 |
/**
|
| 322 |
* Return boolean argument or default value
|
| 323 |
*
|
|
|
|
| 348 |
|
| 349 |
// Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
|
| 350 |
// been set. Also called directly in testing.
|
| 351 |
+
void ForceSetArg(const std::string& arg, const std::string& value);
|
| 352 |
+
void ForceSetArg(const std::string& arg, int64_t value);
|
| 353 |
+
void ForceSetArgV(const std::string& arg, const common::SettingsValue& value);
|
| 354 |
|
| 355 |
/**
|
| 356 |
* Returns the appropriate chain type from the program arguments.
|
|
|
|
| 379 |
/**
|
| 380 |
* Add many hidden arguments
|
| 381 |
*/
|
| 382 |
+
void AddHiddenArgs(const std::vector<std::string>& args, unsigned int flags = ArgsManager::ALLOW_ANY);
|
| 383 |
|
| 384 |
/**
|
| 385 |
* Clear available arguments
|