diff options
| author | Jorge Timón <[email protected]> | 2016-10-13 22:38:10 +0200 |
|---|---|---|
| committer | Jorge Timón <[email protected]> | 2019-09-06 22:05:33 +0200 |
| commit | 052c54ecb02695e5d2694e8e0cbf5ccc89de86e8 (patch) | |
| tree | 6c6aaf45446fdf2e952facf3b87627f08add20f7 /src/util | |
| parent | Merge #16793: refactor: Avoid locking cs_main in ProcessNewBlockHeaders (diff) | |
| download | discoin-052c54ecb02695e5d2694e8e0cbf5ccc89de86e8.tar.xz discoin-052c54ecb02695e5d2694e8e0cbf5ccc89de86e8.zip | |
Testchains: Generic selection with -chain=<str> in addition of -testnet and -regtest
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/system.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp index c925dec25..8098cde09 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -954,16 +954,18 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys) std::string ArgsManager::GetChainName() const { LOCK(cs_args); - bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest"); - bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet"); + const bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest"); + const bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet"); + const bool is_chain_arg_set = IsArgSet("-chain"); - if (fTestNet && fRegTest) - throw std::runtime_error("Invalid combination of -regtest and -testnet."); + if ((int)is_chain_arg_set + (int)fRegTest + (int)fTestNet > 1) { + throw std::runtime_error("Invalid combination of -regtest, -testnet and -chain. Can use at most one."); + } if (fRegTest) return CBaseChainParams::REGTEST; if (fTestNet) return CBaseChainParams::TESTNET; - return CBaseChainParams::MAIN; + return GetArg("-chain", CBaseChainParams::MAIN); } bool RenameOver(fs::path src, fs::path dest) |