mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-03 09:23:01 +01:00
Introduce -testactivationheight=name@height setting
This commit is contained in:
@@ -487,15 +487,30 @@ public:
|
||||
void UpdateActivationParametersFromArgs(const ArgsManager& args);
|
||||
};
|
||||
|
||||
static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& consensus)
|
||||
{
|
||||
for (const std::string& arg : args.GetArgs("-testactivationheight")) {
|
||||
const auto found{arg.find('@')};
|
||||
if (found == std::string::npos) {
|
||||
throw std::runtime_error(strprintf("Invalid format (%s) for -testactivationheight=name@height.", arg));
|
||||
}
|
||||
const auto name{arg.substr(0, found)};
|
||||
const auto value{arg.substr(found + 1)};
|
||||
int32_t height;
|
||||
if (!ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits<int>::max()) {
|
||||
throw std::runtime_error(strprintf("Invalid height value (%s) for -testactivationheight=name@height.", arg));
|
||||
}
|
||||
if (name == "segwit") {
|
||||
consensus.SegwitHeight = int{height};
|
||||
} else {
|
||||
throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
|
||||
{
|
||||
if (args.IsArgSet("-segwitheight")) {
|
||||
int64_t height = args.GetArg("-segwitheight", consensus.SegwitHeight);
|
||||
if (height < 0 || height >= std::numeric_limits<int>::max()) {
|
||||
throw std::runtime_error(strprintf("Activation height %ld for segwit is out of valid range.", height));
|
||||
}
|
||||
consensus.SegwitHeight = static_cast<int>(height);
|
||||
}
|
||||
MaybeUpdateHeights(args, consensus);
|
||||
|
||||
if (!args.IsArgSet("-vbparams")) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user