| 2620 | VersionBitsCache versionbitscache; |
| 2621 | |
| 2622 | int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params) |
| 2623 | { |
| 2624 | //LOCK(cs_main); |
| 2625 | int32_t nVersion = VERSIONBITS_TOP_BITS; |
| 2626 | |
| 2627 | for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) { |
| 2628 | ThresholdState state = VersionBitsState(pindexPrev, params, (Consensus::DeploymentPos)i, versionbitscache); |
| 2629 | if ((Consensus::DeploymentPos)i == Consensus::SMART_CONTRACTS_HARDFORK) { |
| 2630 | int nextHeight = pindexPrev != nullptr ? pindexPrev->nHeight + 1 : 1; |
| 2631 | if (nextHeight >= Params().FirstSCBlock()) { |
| 2632 | nVersion |= VersionBitsMask(params, (Consensus::DeploymentPos)i); |
| 2633 | } |
| 2634 | } else { |
| 2635 | if (state == THRESHOLD_LOCKED_IN || state == THRESHOLD_STARTED) { |
| 2636 | nVersion |= VersionBitsMask(params, (Consensus::DeploymentPos)i); |
| 2637 | } |
| 2638 | } |
| 2639 | } |
| 2640 | |
| 2641 | return nVersion; |
| 2642 | } |
| 2643 | |
| 2644 | /** |
| 2645 | * Threshold condition checker that triggers when unknown versionbits are seen on the network. |
no test coverage detected