v29.4-roots.4 · Commit 2: [PATCH 02/37] 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. The two line-number columns refer to before and after.
src/common/args.h
CHANGED
|
@@ -25,6 +25,7 @@ class ArgsManager;
|
|
|
25
25
|
|
|
26
26
|
extern const char * const BITCOIN_CONF_FILENAME;
|
|
27
27
|
extern const char * const BITCOIN_SETTINGS_FILENAME;
|
|
28
|
+
extern const char * const BITCOIN_RW_CONF_FILENAME;
|
|
28
29
|
|
|
29
30
|
// Return true if -datadir option points to a valid directory or is not specified.
|
|
30
31
|
bool CheckDataDirOption(const ArgsManager& args);
|
|
@@ -65,6 +66,7 @@ enum class OptionsCategory {
|
|
|
65
66
|
REGISTER_COMMANDS,
|
|
66
67
|
CLI_COMMANDS,
|
|
67
68
|
IPC,
|
|
69
|
+
STATS,
|
|
68
70
|
|
|
69
71
|
HIDDEN // Always the last option to avoid printing these in the help
|
|
70
72
|
};
|
|
@@ -92,9 +94,13 @@ std::optional<std::string> SettingToString(const common::SettingsValue&);
|
|
|
92
94
|
int64_t SettingToInt(const common::SettingsValue&, int64_t);
|
|
93
95
|
std::optional<int64_t> SettingToInt(const common::SettingsValue&);
|
|
94
96
|
|
|
97
|
+
std::optional<int64_t> SettingToFixedPoint(const common::SettingsValue&, int decimals);
|
|
98
|
+
|
|
95
99
|
bool SettingToBool(const common::SettingsValue&, bool);
|
|
96
100
|
std::optional<bool> SettingToBool(const common::SettingsValue&);
|
|
97
101
|
|
|
102
|
+
void ModifyRWConfigStream(std::istream& stream_in, std::ostream& stream_out, const std::map<std::string, std::string>& settings_to_change);
|
|
103
|
+
|
|
98
104
|
class ArgsManager
|
|
99
105
|
{
|
|
100
106
|
public:
|
|
@@ -140,11 +146,13 @@ protected:
|
|
|
140
146
|
bool m_accept_any_command GUARDED_BY(cs_args){true};
|
|
141
147
|
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
|
|
142
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};
|
|
143
151
|
mutable fs::path m_cached_blocks_path GUARDED_BY(cs_args);
|
|
144
152
|
mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
|
|
145
153
|
mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
|
|
146
154
|
|
|
147
|
-
[[nodiscard]] bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false);
|
|
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);
|
|
148
156
|
|
|
149
157
|
/**
|
|
150
158
|
* Returns true if settings values from the default section should be used,
|
|
@@ -183,8 +191,14 @@ protected:
|
|
|
183
191
|
*/
|
|
184
192
|
fs::path GetConfigFilePath() const;
|
|
185
193
|
void SetConfigFilePath(fs::path);
|
|
194
|
+
fs::path GetRWConfigFilePath() const;
|
|
186
195
|
[[nodiscard]] bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
|
|
187
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
|
+
|
|
188
202
|
/**
|
|
189
203
|
* Log warnings for options in m_section_only_args when
|
|
190
204
|
* they are specified in the default section but not overridden
|
|
@@ -295,6 +309,15 @@ protected:
|
|
|
295
309
|
int64_t GetIntArg(const std::string& strArg, int64_t nDefault) const;
|
|
296
310
|
std::optional<int64_t> GetIntArg(const std::string& strArg) const;
|
|
297
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
|
+
|
|
298
321
|
/**
|
|
299
322
|
* Return boolean argument or default value
|
|
300
323
|
*
|
|
@@ -325,7 +348,9 @@ protected:
|
|
|
325
348
|
|
|
326
349
|
// Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
|
|
327
350
|
// been set. Also called directly in testing.
|
|
328
|
-
void ForceSetArg(const std::string& strArg, const std::string& strValue);
|
|
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);
|
|
329
354
|
|
|
330
355
|
/**
|
|
331
356
|
* Returns the appropriate chain type from the program arguments.
|
|
@@ -354,7 +379,7 @@ protected:
|
|
|
354
379
|
/**
|
|
355
380
|
* Add many hidden arguments
|
|
356
381
|
*/
|
|
357
|
-
void AddHiddenArgs(const std::vector<std::string>& args);
|
|
382
|
+
void AddHiddenArgs(const std::vector<std::string>& args, unsigned int flags = ArgsManager::ALLOW_ANY);
|
|
358
383
|
|
|
359
384
|
/**
|
|
360
385
|
* Clear available arguments
|