mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-18 19:47:53 +02:00
args: make most ArgsManager members private
Move the first `protected` block (struct Arg, cs_args, m_settings, and all other member variables) to `private`. Only `ReadConfigStream` and `ReadConfigString` remain `protected` for test access. Changes: - Move `ReadConfigString` from `TestArgsManager` into `ArgsManager` itself (declared in args.h, defined in config.cpp) so tests no longer need direct access to `cs_args` or `m_settings` for config parsing. - Replace test-only `SetNetworkOnlyArg` helper with the existing `NETWORK_ONLY` flag passed through `SetupArgs`/`AddArg`. - Remove `TestArgsManager` constructor that cleared `m_network_only_args`. - Remove `using` declarations for `cs_args`, `m_settings`, `GetSetting`, and `GetSettingsList` from `TestArgsManager`. - Clear `m_config_sections` in `ClearArgs()`. Co-authored-by: Anthony Towns <aj@erisian.com.au>
This commit is contained in:
@@ -644,6 +644,7 @@ void ArgsManager::ClearArgs()
|
||||
m_settings = {};
|
||||
m_available_args.clear();
|
||||
m_network_only_args.clear();
|
||||
m_config_sections.clear();
|
||||
}
|
||||
|
||||
void ArgsManager::CheckMultipleCLIArgs() const
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
COMMAND = 0x800,
|
||||
};
|
||||
|
||||
protected:
|
||||
private:
|
||||
struct Arg
|
||||
{
|
||||
std::string m_help_param;
|
||||
@@ -149,8 +149,6 @@ protected:
|
||||
mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
|
||||
mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
|
||||
|
||||
[[nodiscard]] bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false) EXCLUSIVE_LOCKS_REQUIRED(!cs_args);
|
||||
|
||||
/**
|
||||
* Returns true if settings values from the default section should be used,
|
||||
* depending on the current network and whether the setting is
|
||||
@@ -158,7 +156,11 @@ protected:
|
||||
*/
|
||||
bool UseDefaultSection(const std::string& arg) const EXCLUSIVE_LOCKS_REQUIRED(cs_args);
|
||||
|
||||
public:
|
||||
protected:
|
||||
[[nodiscard]] bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false) EXCLUSIVE_LOCKS_REQUIRED(!cs_args);
|
||||
[[nodiscard]] bool ReadConfigString(const std::string& str_config) EXCLUSIVE_LOCKS_REQUIRED(!cs_args);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Get setting value.
|
||||
*
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -119,6 +120,18 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& file
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArgsManager::ReadConfigString(const std::string& str_config)
|
||||
{
|
||||
std::istringstream streamConfig(str_config);
|
||||
{
|
||||
LOCK(cs_args);
|
||||
m_settings.ro_config.clear();
|
||||
m_config_sections.clear();
|
||||
}
|
||||
std::string error;
|
||||
return ReadConfigStream(streamConfig, "", error);
|
||||
}
|
||||
|
||||
bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||
{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user