mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-07 19:22:17 +01:00
ArgsManager: Warn when ignoring network-specific config setting
When network-specific options such as -addnode, -connect, etc are specified in the default section of the config file, but that setting is ignored due to testnet or regtest being in use, and it is not overridden by either a command line option or a setting in the [regtest] or [test] section of the config file, a warning is added to the log, eg: Warning: Config setting for -connect only applied on regtest network when in [regtest] section.
This commit is contained in:
28
src/util.cpp
28
src/util.cpp
@@ -600,6 +600,34 @@ ArgsManager::ArgsManager() :
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
void ArgsManager::WarnForSectionOnlyArgs()
|
||||
{
|
||||
// if there's no section selected, don't worry
|
||||
if (m_network.empty()) return;
|
||||
|
||||
// if it's okay to use the default section for this network, don't worry
|
||||
if (m_network == CBaseChainParams::MAIN) return;
|
||||
|
||||
for (const auto& arg : m_network_only_args) {
|
||||
std::pair<bool, std::string> found_result;
|
||||
|
||||
// if this option is overridden it's fine
|
||||
found_result = ArgsManagerHelper::GetArgHelper(m_override_args, arg);
|
||||
if (found_result.first) continue;
|
||||
|
||||
// if there's a network-specific value for this option, it's fine
|
||||
found_result = ArgsManagerHelper::GetArgHelper(m_config_args, ArgsManagerHelper::NetworkArg(*this, arg));
|
||||
if (found_result.first) continue;
|
||||
|
||||
// if there isn't a default value for this option, it's fine
|
||||
found_result = ArgsManagerHelper::GetArgHelper(m_config_args, arg);
|
||||
if (!found_result.first) continue;
|
||||
|
||||
// otherwise, issue a warning
|
||||
LogPrintf("Warning: Config setting for %s only applied on %s network when in [%s] section.\n", arg, m_network, m_network);
|
||||
}
|
||||
}
|
||||
|
||||
void ArgsManager::SelectConfigNetwork(const std::string& network)
|
||||
{
|
||||
m_network = network;
|
||||
|
||||
Reference in New Issue
Block a user