mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
refactor: Clean up long lines in settings code
Suggested by James O'Beirne <james.obeirne@gmail.com> https://github.com/bitcoin/bitcoin/pull/15934#discussion_r344366743 This commit does not change behavior.
This commit is contained in:
parent
cd6cb9745e
commit
3f7dc9b808
2 changed files with 19 additions and 5 deletions
|
@ -68,7 +68,9 @@ SettingsValue GetSetting(const Settings& settings,
|
||||||
// precedence over early settings, but for backwards compatibility in
|
// precedence over early settings, but for backwards compatibility in
|
||||||
// the config file the precedence is reversed for all settings except
|
// the config file the precedence is reversed for all settings except
|
||||||
// chain name settings.
|
// chain name settings.
|
||||||
const bool reverse_precedence = (source == Source::CONFIG_FILE_NETWORK_SECTION || source == Source::CONFIG_FILE_DEFAULT_SECTION) && !get_chain_name;
|
const bool reverse_precedence =
|
||||||
|
(source == Source::CONFIG_FILE_NETWORK_SECTION || source == Source::CONFIG_FILE_DEFAULT_SECTION) &&
|
||||||
|
!get_chain_name;
|
||||||
|
|
||||||
// Weird behavior preserved for backwards compatibility: Negated
|
// Weird behavior preserved for backwards compatibility: Negated
|
||||||
// -regtest and -testnet arguments which you would expect to override
|
// -regtest and -testnet arguments which you would expect to override
|
||||||
|
@ -78,7 +80,10 @@ SettingsValue GetSetting(const Settings& settings,
|
||||||
const bool skip_negated_command_line = get_chain_name;
|
const bool skip_negated_command_line = get_chain_name;
|
||||||
|
|
||||||
// Ignore settings in default config section if requested.
|
// Ignore settings in default config section if requested.
|
||||||
if (ignore_default_section_config && source == Source::CONFIG_FILE_DEFAULT_SECTION && !never_ignore_negated_setting) return;
|
if (ignore_default_section_config && source == Source::CONFIG_FILE_DEFAULT_SECTION &&
|
||||||
|
!never_ignore_negated_setting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip negated command line settings.
|
// Skip negated command line settings.
|
||||||
if (skip_negated_command_line && span.last_negated()) return;
|
if (skip_negated_command_line && span.last_negated()) return;
|
||||||
|
@ -111,7 +116,9 @@ std::vector<SettingsValue> GetSettingsList(const Settings& settings,
|
||||||
// value is followed by non-negated value, in which case config file
|
// value is followed by non-negated value, in which case config file
|
||||||
// settings will be brought back from the dead (but earlier command
|
// settings will be brought back from the dead (but earlier command
|
||||||
// line settings will still be ignored).
|
// line settings will still be ignored).
|
||||||
const bool add_zombie_config_values = (source == Source::CONFIG_FILE_NETWORK_SECTION || source == Source::CONFIG_FILE_DEFAULT_SECTION) && !prev_negated_empty;
|
const bool add_zombie_config_values =
|
||||||
|
(source == Source::CONFIG_FILE_NETWORK_SECTION || source == Source::CONFIG_FILE_DEFAULT_SECTION) &&
|
||||||
|
!prev_negated_empty;
|
||||||
|
|
||||||
// Ignore settings in default config section if requested.
|
// Ignore settings in default config section if requested.
|
||||||
if (ignore_default_section_config && source == Source::CONFIG_FILE_DEFAULT_SECTION) return;
|
if (ignore_default_section_config && source == Source::CONFIG_FILE_DEFAULT_SECTION) return;
|
||||||
|
|
|
@ -43,11 +43,18 @@ struct Settings {
|
||||||
//! [section] keywords)
|
//! [section] keywords)
|
||||||
//! @param get_chain_name - enable special backwards compatible behavior
|
//! @param get_chain_name - enable special backwards compatible behavior
|
||||||
//! for GetChainName
|
//! for GetChainName
|
||||||
SettingsValue GetSetting(const Settings& settings, const std::string& section, const std::string& name, bool ignore_default_section_config, bool get_chain_name);
|
SettingsValue GetSetting(const Settings& settings,
|
||||||
|
const std::string& section,
|
||||||
|
const std::string& name,
|
||||||
|
bool ignore_default_section_config,
|
||||||
|
bool get_chain_name);
|
||||||
|
|
||||||
//! Get combined setting value similar to GetSetting(), except if setting was
|
//! Get combined setting value similar to GetSetting(), except if setting was
|
||||||
//! specified multiple times, return a list of all the values specified.
|
//! specified multiple times, return a list of all the values specified.
|
||||||
std::vector<SettingsValue> GetSettingsList(const Settings& settings, const std::string& section, const std::string& name, bool ignore_default_section_config);
|
std::vector<SettingsValue> GetSettingsList(const Settings& settings,
|
||||||
|
const std::string& section,
|
||||||
|
const std::string& name,
|
||||||
|
bool ignore_default_section_config);
|
||||||
|
|
||||||
//! Return true if a setting is set in the default config file section, and not
|
//! Return true if a setting is set in the default config file section, and not
|
||||||
//! overridden by a higher priority command-line or network section value.
|
//! overridden by a higher priority command-line or network section value.
|
||||||
|
|
Loading…
Add table
Reference in a new issue