v30.3-roots.1 · Commit 2: [PATCH 02/68] feat(runtime): preserve Roots operator controls on Core 30.3
src/common/args.h
Before: src/common/args.h · After: src/common/args.h
File metadata
index d907ad7663de3d5d0a60e087ced1bd388821d13c..4b5c2e723b3a3160ed559e6734317e1f5ac01bb2 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:
|
|
@@ -141,11 +147,13 @@ protected:
|
|
| 141 |
bool m_accept_any_command GUARDED_BY(cs_args){true};
|
| 142 |
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
|
| 143 |
std::optional<fs::path> m_config_path GUARDED_BY(cs_args);
|
|
|
|
|
|
|
| 144 |
mutable fs::path m_cached_blocks_path GUARDED_BY(cs_args);
|
| 145 |
mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
|
| 146 |
mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
|
| 147 |
|
| 148 |
-
[[nodiscard]] bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false);
|
| 149 |
|
| 150 |
/**
|
| 151 |
* Returns true if settings values from the default section should be used,
|
|
@@ -184,8 +192,14 @@ protected:
|
|
| 184 |
*/
|
| 185 |
fs::path GetConfigFilePath() const;
|
| 186 |
void SetConfigFilePath(fs::path);
|
|
|
|
| 187 |
[[nodiscard]] bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
/**
|
| 190 |
* Log warnings for options in m_section_only_args when
|
| 191 |
* they are specified in the default section but not overridden
|
|
@@ -296,6 +310,15 @@ protected:
|
|
| 296 |
int64_t GetIntArg(const std::string& strArg, int64_t nDefault) const;
|
| 297 |
std::optional<int64_t> GetIntArg(const std::string& strArg) const;
|
| 298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
/**
|
| 300 |
* Return boolean argument or default value
|
| 301 |
*
|
|
@@ -326,7 +349,9 @@ protected:
|
|
| 326 |
|
| 327 |
// Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
|
| 328 |
// been set. Also called directly in testing.
|
| 329 |
-
void ForceSetArg(const std::string& strArg, const std::string& strValue);
|
|
|
|
|
|
|
| 330 |
|
| 331 |
/**
|
| 332 |
* Returns the appropriate chain type from the program arguments.
|
|
@@ -355,7 +380,7 @@ protected:
|
|
| 355 |
/**
|
| 356 |
* Add many hidden arguments
|
| 357 |
*/
|
| 358 |
-
void AddHiddenArgs(const std::vector<std::string>& args);
|
| 359 |
|
| 360 |
/**
|
| 361 |
* 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:
|
|
|
|
| 147 |
bool m_accept_any_command GUARDED_BY(cs_args){true};
|
| 148 |
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
|
| 149 |
std::optional<fs::path> m_config_path GUARDED_BY(cs_args);
|
| 150 |
+
std::optional<fs::path> m_rwconf_path GUARDED_BY(cs_args);
|
| 151 |
+
bool m_rwconf_had_prune_option{false};
|
| 152 |
mutable fs::path m_cached_blocks_path GUARDED_BY(cs_args);
|
| 153 |
mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
|
| 154 |
mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
|
| 155 |
|
| 156 |
+
[[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);
|
| 157 |
|
| 158 |
/**
|
| 159 |
* Returns true if settings values from the default section should be used,
|
|
|
|
| 192 |
*/
|
| 193 |
fs::path GetConfigFilePath() const;
|
| 194 |
void SetConfigFilePath(fs::path);
|
| 195 |
+
fs::path GetRWConfigFilePath() const;
|
| 196 |
[[nodiscard]] bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
|
| 197 |
|
| 198 |
+
bool RWConfigHasPruneOption() const { return m_rwconf_had_prune_option; }
|
| 199 |
+
void ModifyRWConfigFile(const std::map<std::string, std::string>& settings_to_change, bool also_settings_json = true);
|
| 200 |
+
void ModifyRWConfigFile(const std::string& setting_to_change, const std::string& new_value, bool also_settings_json = true);
|
| 201 |
+
void EraseRWConfigFile();
|
| 202 |
+
|
| 203 |
/**
|
| 204 |
* Log warnings for options in m_section_only_args when
|
| 205 |
* they are specified in the default section but not overridden
|
|
|
|
| 310 |
int64_t GetIntArg(const std::string& strArg, int64_t nDefault) const;
|
| 311 |
std::optional<int64_t> GetIntArg(const std::string& strArg) const;
|
| 312 |
|
| 313 |
+
/**
|
| 314 |
+
* Return fixed-point argument
|
| 315 |
+
*
|
| 316 |
+
* @param arg Argument to get (e.g. "-foo")
|
| 317 |
+
* @param decimals Number of fractional decimal digits to accept
|
| 318 |
+
* @return Command-line argument (0 if invalid number) multiplied by 10**decimals
|
| 319 |
+
*/
|
| 320 |
+
std::optional<int64_t> GetFixedPointArg(const std::string& arg, int decimals) const;
|
| 321 |
+
|
| 322 |
/**
|
| 323 |
* Return boolean argument or default value
|
| 324 |
*
|
|
|
|
| 349 |
|
| 350 |
// Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
|
| 351 |
// been set. Also called directly in testing.
|
| 352 |
+
void ForceSetArg(const std::string& arg, const std::string& value);
|
| 353 |
+
void ForceSetArg(const std::string& arg, int64_t value);
|
| 354 |
+
void ForceSetArgV(const std::string& arg, const common::SettingsValue& value);
|
| 355 |
|
| 356 |
/**
|
| 357 |
* Returns the appropriate chain type from the program arguments.
|
|
|
|
| 380 |
/**
|
| 381 |
* Add many hidden arguments
|
| 382 |
*/
|
| 383 |
+
void AddHiddenArgs(const std::vector<std::string>& args, unsigned int flags = ArgsManager::ALLOW_ANY);
|
| 384 |
|
| 385 |
/**
|
| 386 |
* Clear available arguments
|