Skip to content
Bitcoin Roots

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. 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:
@@ -141,11 +147,13 @@ protected:
141
147
  bool m_accept_any_command GUARDED_BY(cs_args){true};
142
148
  std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
143
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};
144
152
  mutable fs::path m_cached_blocks_path GUARDED_BY(cs_args);
145
153
  mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
146
154
  mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
147
155
 
148
- [[nodiscard]] bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false);
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);
149
157
 
150
158
  /**
151
159
  * Returns true if settings values from the default section should be used,
@@ -184,8 +192,14 @@ protected:
184
192
  */
185
193
  fs::path GetConfigFilePath() const;
186
194
  void SetConfigFilePath(fs::path);
195
+ fs::path GetRWConfigFilePath() const;
187
196
  [[nodiscard]] bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
188
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
+
189
203
  /**
190
204
  * Log warnings for options in m_section_only_args when
191
205
  * they are specified in the default section but not overridden
@@ -296,6 +310,15 @@ protected:
296
310
  int64_t GetIntArg(const std::string& strArg, int64_t nDefault) const;
297
311
  std::optional<int64_t> GetIntArg(const std::string& strArg) const;
298
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
+
299
322
  /**
300
323
  * Return boolean argument or default value
301
324
  *
@@ -326,7 +349,9 @@ protected:
326
349
 
327
350
  // Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
328
351
  // been set. Also called directly in testing.
329
- void ForceSetArg(const std::string& strArg, const std::string& strValue);
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);
330
355
 
331
356
  /**
332
357
  * Returns the appropriate chain type from the program arguments.
@@ -355,7 +380,7 @@ protected:
355
380
  /**
356
381
  * Add many hidden arguments
357
382
  */
358
- void AddHiddenArgs(const std::vector<std::string>& args);
383
+ void AddHiddenArgs(const std::vector<std::string>& args, unsigned int flags = ArgsManager::ALLOW_ANY);
359
384
 
360
385
  /**
361
386
  * Clear available arguments