* Allows modifying the Version Bits Elements regtest parameters (and liquidv1test). * Ideally, this would be a method in the base class, inherited everywhere, but that might complicate future merges, * so we settle for this static function. */
| 89 | * so we settle for this static function. |
| 90 | */ |
| 91 | static void UpdateElementsActivationParametersFromArgs(Consensus::Params& consensus, const ArgsManager& args) |
| 92 | { |
| 93 | if (!args.IsArgSet("-evbparams")) return; |
| 94 | |
| 95 | std::map<std::string,int> map_deployments; |
| 96 | for (const std::string& strDeployment : args.GetArgs("-evbparams")) { |
| 97 | std::vector<std::string> vDeploymentParams; |
| 98 | boost::split(vDeploymentParams, strDeployment, boost::is_any_of(":")); |
| 99 | if (vDeploymentParams.size() != 5) { |
| 100 | throw std::runtime_error("ElementsVersion bits parameters malformed, expecting deployment:start:end:period:threshold"); |
| 101 | } |
| 102 | int64_t nStartTime = 0, nTimeout = 0, nPeriod = 0, nThreshold = 0; |
| 103 | bool use_nStartTime = false, use_nTimeout = false, use_nPeriod = false, use_nThreshold = false; |
| 104 | if(vDeploymentParams[1].length()) { |
| 105 | if (!ParseInt64(vDeploymentParams[1], &nStartTime)) { |
| 106 | throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1])); |
| 107 | } |
| 108 | use_nStartTime = true; |
| 109 | } |
| 110 | if(vDeploymentParams[2].length()) { |
| 111 | if (!ParseInt64(vDeploymentParams[2], &nTimeout)) { |
| 112 | throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2])); |
| 113 | } |
| 114 | use_nTimeout = true; |
| 115 | } |
| 116 | if(vDeploymentParams[3].length()) { |
| 117 | if (!ParseInt64(vDeploymentParams[3], &nPeriod)) { |
| 118 | throw std::runtime_error(strprintf("Invalid nPeriod (%s)", vDeploymentParams[3])); |
| 119 | } |
| 120 | use_nPeriod = true; |
| 121 | } |
| 122 | if(vDeploymentParams[4].length()) { |
| 123 | if (!ParseInt64(vDeploymentParams[4], &nThreshold)) { |
| 124 | throw std::runtime_error(strprintf("Invalid nThreshold (%s)", vDeploymentParams[4])); |
| 125 | } |
| 126 | use_nThreshold = true; |
| 127 | } |
| 128 | bool found = false; |
| 129 | for (int j=0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) { |
| 130 | if (vDeploymentParams[0] == VersionBitsDeploymentInfo[j].name) { |
| 131 | if(map_deployments[vDeploymentParams[0]]) { |
| 132 | found = true; |
| 133 | LogPrintf("Ignoring duplicated version bits activation parameters for \"%s\"\n", strDeployment.c_str()); |
| 134 | break; |
| 135 | } |
| 136 | std::string extra_logging; |
| 137 | map_deployments[vDeploymentParams[0]]=1; |
| 138 | Consensus::DeploymentPos d=Consensus::DeploymentPos(j); |
| 139 | if (use_nStartTime) { |
| 140 | consensus.vDeployments[d].nStartTime = nStartTime; |
| 141 | } else { |
| 142 | nStartTime =consensus.vDeployments[d].nStartTime; |
| 143 | } |
| 144 | if (use_nTimeout) { |
| 145 | consensus.vDeployments[d].nTimeout = nTimeout; |
| 146 | } else { |
| 147 | nTimeout = consensus.vDeployments[d].nTimeout; |
| 148 | } |
no test coverage detected