1 // Copyright (c) 2009-2010 Satoshi Nakamoto 2 // Copyright (c) 2009-2018 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 #include <limits> 11 #include <map> 12 #include <string> 13 14 namespace Consensus { 15 16 enum DeploymentPos 17 { 18 DEPLOYMENT_TESTDUMMY, 19 DEPLOYMENT_CSV, // Deployment of BIP68, BIP112, and BIP113. 20 DEPLOYMENT_SEGWIT, // Deployment of BIP141, BIP143, and BIP147. 21 // NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp 22 MAX_VERSION_BITS_DEPLOYMENTS 23 }; 24 25 /** 26 * Struct for each individual consensus rule change using BIP9. 27 */ 28 struct BIP9Deployment { 29 /** Bit position to select the particular bit in nVersion. */ 30 int bit; 31 /** Start MedianTime for version bits miner confirmation. Can be a date in the past */ 32 int64_t nStartTime; 33 /** Timeout/expiry MedianTime for the deployment attempt. */ 34 int64_t nTimeout; 35 36 /** Constant for nTimeout very far in the future. */ 37 static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max(); 38 39 /** Special value for nStartTime indicating that the deployment is always active. 40 * This is useful for testing, as it means tests don't need to deal with the activation 41 * process (which takes at least 3 BIP9 intervals). Only tests that specifically test the 42 * behaviour during activation cannot use this. */ 43 static constexpr int64_t ALWAYS_ACTIVE = -1; 44 }; 45 46 /** 47 * Parameters that influence chain consensus. 48 */ 49 struct Params { 50 uint256 hashGenesisBlock; 51 int nSubsidyHalvingInterval; 52 /** Block height at which BIP16 becomes active */ 53 int BIP16Height; 54 /** Block height and hash at which BIP34 becomes active */ 55 int BIP34Height; 56 uint256 BIP34Hash; 57 /** Block height at which BIP65 becomes active */ 58 int BIP65Height; 59 /** Block height at which BIP66 becomes active */ 60 int BIP66Height; 61 /** 62 * Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period, 63 * (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments. 64 * Examples: 1916 for 95%, 1512 for testchains. 65 */ 66 uint32_t nRuleChangeActivationThreshold; 67 uint32_t nMinerConfirmationWindow; 68 BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]; 69 /** Proof of work parameters */ 70 uint256 powLimit; 71 bool fPowAllowMinDifficultyBlocks; 72 bool fPowNoRetargeting; 73 int64_t nPowTargetSpacing; 74 int64_t nPowTargetTimespan; DifficultyAdjustmentIntervalParams75 int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; } 76 uint256 nMinimumChainWork; 77 uint256 defaultAssumeValid; 78 }; 79 } // namespace Consensus 80 81 #endif // BITCOIN_CONSENSUS_PARAMS_H 82