LCOV - code coverage report
Current view: top level - src - deploymentstatus.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 20 20 100.0 %
Date: 2026-06-25 07:23:43 Functions: 7 7 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2020-2021 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #ifndef BITCOIN_DEPLOYMENTSTATUS_H
       6             : #define BITCOIN_DEPLOYMENTSTATUS_H
       7             : 
       8             : #include <chain.h>
       9             : #include <versionbits.h>
      10             : 
      11             : #include <limits>
      12             : 
      13             : /** Determine if a deployment is active for the next block */
      14    11410903 : inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::BuriedDeployment dep)
      15             : {
      16    11410903 :     assert(Consensus::ValidDeployment(dep));
      17    11410903 :     return (pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1) >= params.DeploymentHeight(dep);
      18             : }
      19             : 
      20      982859 : inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos dep, VersionBitsCache& versionbitscache)
      21             : {
      22      982859 :     assert(Consensus::ValidDeployment(dep));
      23      982859 :     return ThresholdState::ACTIVE == versionbitscache.State(pindexPrev, params, dep);
      24             : }
      25             : 
      26             : /** Determine if a deployment is active for this block */
      27     8970309 : inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::BuriedDeployment dep)
      28             : {
      29     8970309 :     assert(Consensus::ValidDeployment(dep));
      30     8970309 :     return index.nHeight >= params.DeploymentHeight(dep);
      31             : }
      32             : 
      33      130205 : inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::DeploymentPos dep, VersionBitsCache& versionbitscache)
      34             : {
      35      130205 :     assert(Consensus::ValidDeployment(dep));
      36      130205 :     return DeploymentActiveAfter(index.pprev, params, dep, versionbitscache);
      37             : }
      38             : 
      39             : /** Determine if a deployment is enabled (can ever be active) */
      40      227040 : inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::BuriedDeployment dep)
      41             : {
      42      227040 :     assert(Consensus::ValidDeployment(dep));
      43      227040 :     return params.DeploymentHeight(dep) != std::numeric_limits<int>::max();
      44             : }
      45             : 
      46       30272 : inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::DeploymentPos dep)
      47             : {
      48       30272 :     assert(Consensus::ValidDeployment(dep));
      49       30272 :     return params.vDeployments[dep].nStartTime != Consensus::BIP9Deployment::NEVER_ACTIVE;
      50             : }
      51             : 
      52             : /** this function is convenient helper for DIP0003 because 'active' and 'enforced' are different statuses for DIP0003 */
      53      728152 : constexpr bool DeploymentDIP0003Enforced(const int nHeight, const Consensus::Params& params)
      54             : {
      55      728152 :     return nHeight >= params.DIP0003EnforcementHeight;
      56             : }
      57             : 
      58             : #endif // BITCOIN_DEPLOYMENTSTATUS_H

Generated by: LCOV version 1.16