LCOV - code coverage report
Current view: top level - src/consensus - params.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 17 18 94.4 %
Date: 2022-04-21 14:51:19 Functions: 4 4 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 11 12 91.7 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2009-2010 Satoshi Nakamoto
#       2                 :            : // Copyright (c) 2009-2021 The Bitcoin Core developers
#       3                 :            : // Distributed under the MIT software license, see the accompanying
#       4                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#       5                 :            : 
#       6                 :            : #ifndef BITCOIN_CONSENSUS_PARAMS_H
#       7                 :            : #define BITCOIN_CONSENSUS_PARAMS_H
#       8                 :            : 
#       9                 :            : #include <uint256.h>
#      10                 :            : 
#      11                 :            : #include <limits>
#      12                 :            : #include <map>
#      13                 :            : 
#      14                 :            : namespace Consensus {
#      15                 :            : 
#      16                 :            : /**
#      17                 :            :  * A buried deployment is one where the height of the activation has been hardcoded into
#      18                 :            :  * the client implementation long after the consensus change has activated. See BIP 90.
#      19                 :            :  */
#      20                 :            : enum BuriedDeployment : int16_t {
#      21                 :            :     // buried deployments get negative values to avoid overlap with DeploymentPos
#      22                 :            :     DEPLOYMENT_HEIGHTINCB = std::numeric_limits<int16_t>::min(),
#      23                 :            :     DEPLOYMENT_CLTV,
#      24                 :            :     DEPLOYMENT_DERSIG,
#      25                 :            :     DEPLOYMENT_CSV,
#      26                 :            :     DEPLOYMENT_SEGWIT,
#      27                 :            : };
#      28                 :    1118564 : constexpr bool ValidDeployment(BuriedDeployment dep) { return dep <= DEPLOYMENT_SEGWIT; }
#      29                 :            : 
#      30                 :            : enum DeploymentPos : uint16_t {
#      31                 :            :     DEPLOYMENT_TESTDUMMY,
#      32                 :            :     DEPLOYMENT_TAPROOT, // Deployment of Schnorr/Taproot (BIPs 340-342)
#      33                 :            :     // NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp
#      34                 :            :     MAX_VERSION_BITS_DEPLOYMENTS
#      35                 :            : };
#      36                 :        344 : constexpr bool ValidDeployment(DeploymentPos dep) { return dep < MAX_VERSION_BITS_DEPLOYMENTS; }
#      37                 :            : 
#      38                 :            : /**
#      39                 :            :  * Struct for each individual consensus rule change using BIP9.
#      40                 :            :  */
#      41                 :            : struct BIP9Deployment {
#      42                 :            :     /** Bit position to select the particular bit in nVersion. */
#      43                 :            :     int bit;
#      44                 :            :     /** Start MedianTime for version bits miner confirmation. Can be a date in the past */
#      45                 :            :     int64_t nStartTime;
#      46                 :            :     /** Timeout/expiry MedianTime for the deployment attempt. */
#      47                 :            :     int64_t nTimeout;
#      48                 :            :     /** If lock in occurs, delay activation until at least this block
#      49                 :            :      *  height.  Note that activation will only occur on a retarget
#      50                 :            :      *  boundary.
#      51                 :            :      */
#      52                 :            :     int min_activation_height{0};
#      53                 :            : 
#      54                 :            :     /** Constant for nTimeout very far in the future. */
#      55                 :            :     static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max();
#      56                 :            : 
#      57                 :            :     /** Special value for nStartTime indicating that the deployment is always active.
#      58                 :            :      *  This is useful for testing, as it means tests don't need to deal with the activation
#      59                 :            :      *  process (which takes at least 3 BIP9 intervals). Only tests that specifically test the
#      60                 :            :      *  behaviour during activation cannot use this. */
#      61                 :            :     static constexpr int64_t ALWAYS_ACTIVE = -1;
#      62                 :            : 
#      63                 :            :     /** Special value for nStartTime indicating that the deployment is never active.
#      64                 :            :      *  This is useful for integrating the code changes for a new feature
#      65                 :            :      *  prior to deploying it on some or all networks. */
#      66                 :            :     static constexpr int64_t NEVER_ACTIVE = -2;
#      67                 :            : };
#      68                 :            : 
#      69                 :            : /**
#      70                 :            :  * Parameters that influence chain consensus.
#      71                 :            :  */
#      72                 :            : struct Params {
#      73                 :            :     uint256 hashGenesisBlock;
#      74                 :            :     int nSubsidyHalvingInterval;
#      75                 :            :     /**
#      76                 :            :      * Hashes of blocks that
#      77                 :            :      * - are known to be consensus valid, and
#      78                 :            :      * - buried in the chain, and
#      79                 :            :      * - fail if the default script verify flags are applied.
#      80                 :            :      */
#      81                 :            :     std::map<uint256, uint32_t> script_flag_exceptions;
#      82                 :            :     /** Block height and hash at which BIP34 becomes active */
#      83                 :            :     int BIP34Height;
#      84                 :            :     uint256 BIP34Hash;
#      85                 :            :     /** Block height at which BIP65 becomes active */
#      86                 :            :     int BIP65Height;
#      87                 :            :     /** Block height at which BIP66 becomes active */
#      88                 :            :     int BIP66Height;
#      89                 :            :     /** Block height at which CSV (BIP68, BIP112 and BIP113) becomes active */
#      90                 :            :     int CSVHeight;
#      91                 :            :     /** Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active.
#      92                 :            :      * Note that segwit v0 script rules are enforced on all blocks except the
#      93                 :            :      * BIP 16 exception blocks. */
#      94                 :            :     int SegwitHeight;
#      95                 :            :     /** Don't warn about unknown BIP 9 activations below this height.
#      96                 :            :      * This prevents us from warning about the CSV and segwit activations. */
#      97                 :            :     int MinBIP9WarningHeight;
#      98                 :            :     /**
#      99                 :            :      * Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,
#     100                 :            :      * (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments.
#     101                 :            :      * Examples: 1916 for 95%, 1512 for testchains.
#     102                 :            :      */
#     103                 :            :     uint32_t nRuleChangeActivationThreshold;
#     104                 :            :     uint32_t nMinerConfirmationWindow;
#     105                 :            :     BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS];
#     106                 :            :     /** Proof of work parameters */
#     107                 :            :     uint256 powLimit;
#     108                 :            :     bool fPowAllowMinDifficultyBlocks;
#     109                 :            :     bool fPowNoRetargeting;
#     110                 :            :     int64_t nPowTargetSpacing;
#     111                 :            :     int64_t nPowTargetTimespan;
#     112                 :   44894346 :     int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; }
#     113                 :            :     /** The best chain should have at least this much work */
#     114                 :            :     uint256 nMinimumChainWork;
#     115                 :            :     /** By default assume that the signatures in ancestors of this block are valid */
#     116                 :            :     uint256 defaultAssumeValid;
#     117                 :            : 
#     118                 :            :     /**
#     119                 :            :      * If true, witness commitments contain a payload equal to a Bitcoin Script solution
#     120                 :            :      * to the signet challenge. See BIP325.
#     121                 :            :      */
#     122                 :            :     bool signet_blocks{false};
#     123                 :            :     std::vector<uint8_t> signet_challenge;
#     124                 :            : 
#     125                 :            :     int DeploymentHeight(BuriedDeployment dep) const
#     126                 :    1118564 :     {
#     127         [ -  + ]:    1118564 :         switch (dep) {
#     128         [ +  + ]:      93198 :         case DEPLOYMENT_HEIGHTINCB:
#     129                 :      93198 :             return BIP34Height;
#     130         [ +  + ]:     119961 :         case DEPLOYMENT_CLTV:
#     131                 :     119961 :             return BIP65Height;
#     132         [ +  + ]:     119960 :         case DEPLOYMENT_DERSIG:
#     133                 :     119960 :             return BIP66Height;
#     134         [ +  + ]:     305792 :         case DEPLOYMENT_CSV:
#     135                 :     305792 :             return CSVHeight;
#     136         [ +  + ]:     479653 :         case DEPLOYMENT_SEGWIT:
#     137                 :     479653 :             return SegwitHeight;
#     138                 :    1118564 :         } // no default case, so the compiler can warn about missing cases
#     139                 :          0 :         return std::numeric_limits<int>::max();
#     140                 :    1118564 :     }
#     141                 :            : };
#     142                 :            : 
#     143                 :            : } // namespace Consensus
#     144                 :            : 
#     145                 :            : #endif // BITCOIN_CONSENSUS_PARAMS_H

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a