| 245 | } |
| 246 | |
| 247 | int32_t VersionBitsCache::ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params) |
| 248 | { |
| 249 | LOCK(m_mutex); |
| 250 | int32_t nVersion = VERSIONBITS_TOP_BITS; |
| 251 | |
| 252 | for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) { |
| 253 | Consensus::DeploymentPos pos = static_cast<Consensus::DeploymentPos>(i); |
| 254 | ThresholdState state = VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, m_caches[pos]); |
| 255 | if (state == ThresholdState::LOCKED_IN || state == ThresholdState::STARTED) { |
| 256 | nVersion |= Mask(params, pos); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | if (!gArgs.GetBoolArg("-con_dyna_deploy_signal", true)) { |
| 261 | auto dynafed = Consensus::DeploymentPos::DEPLOYMENT_DYNA_FED; |
| 262 | int bit = params.vDeployments[dynafed].bit; |
| 263 | if (bit > 0 && bit < VERSIONBITS_NUM_BITS) { |
| 264 | nVersion &= ~Mask(params, dynafed); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | return nVersion; |
| 269 | } |
| 270 | |
| 271 | void VersionBitsCache::Clear() |
| 272 | { |