MCPcopy Create free account
hub / github.com/ElementsProject/elements / UpdateActivationParametersFromArgs

Method UpdateActivationParametersFromArgs

src/chainparams.cpp:757–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

755}
756
757void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
758{
759 MaybeUpdateHeights(args, consensus);
760
761 if (!args.IsArgSet("-vbparams")) return;
762
763 for (const std::string& strDeployment : args.GetArgs("-vbparams")) {
764 std::vector<std::string> vDeploymentParams;
765 boost::split(vDeploymentParams, strDeployment, boost::is_any_of(":"));
766 if (vDeploymentParams.size() < 3 || 4 < vDeploymentParams.size()) {
767 throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
768 }
769 int64_t nStartTime, nTimeout;
770 int min_activation_height = 0;
771 if (!ParseInt64(vDeploymentParams[1], &nStartTime)) {
772 throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1]));
773 }
774 if (!ParseInt64(vDeploymentParams[2], &nTimeout)) {
775 throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2]));
776 }
777 if (vDeploymentParams.size() >= 4 && !ParseInt32(vDeploymentParams[3], &min_activation_height)) {
778 throw std::runtime_error(strprintf("Invalid min_activation_height (%s)", vDeploymentParams[3]));
779 }
780 bool found = false;
781 for (int j=0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
782 if (vDeploymentParams[0] == VersionBitsDeploymentInfo[j].name) {
783 UpdateVersionBitsParameters(Consensus::DeploymentPos(j), nStartTime, nTimeout, min_activation_height);
784 found = true;
785 LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld, min_activation_height=%d\n", vDeploymentParams[0], nStartTime, nTimeout, min_activation_height);
786 break;
787 }
788 }
789 if (!found) {
790 throw std::runtime_error(strprintf("Invalid deployment (%s)", vDeploymentParams[0]));
791 }
792 }
793}
794
795/**
796 * Custom params for testing.

Callers

nothing calls this directly

Calls 7

MaybeUpdateHeightsFunction · 0.85
DeploymentPosEnum · 0.85
IsArgSetMethod · 0.80
GetArgsMethod · 0.80
ParseInt64Function · 0.50
ParseInt32Function · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected