LCOV - code coverage report
Current view: top level - src - chainparams.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 24 26 92.3 %
Date: 2021-06-29 14:35:33 Functions: 21 23 91.3 %
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: 0 0 -

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2009-2010 Satoshi Nakamoto
#       2                 :            : // Copyright (c) 2009-2020 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_CHAINPARAMS_H
#       7                 :            : #define BITCOIN_CHAINPARAMS_H
#       8                 :            : 
#       9                 :            : #include <chainparamsbase.h>
#      10                 :            : #include <consensus/params.h>
#      11                 :            : #include <primitives/block.h>
#      12                 :            : #include <protocol.h>
#      13                 :            : #include <util/hash_type.h>
#      14                 :            : 
#      15                 :            : #include <memory>
#      16                 :            : #include <vector>
#      17                 :            : 
#      18                 :            : typedef std::map<int, uint256> MapCheckpoints;
#      19                 :            : 
#      20                 :            : struct CCheckpointData {
#      21                 :            :     MapCheckpoints mapCheckpoints;
#      22                 :            : 
#      23                 :       1536 :     int GetHeight() const {
#      24                 :       1536 :         const auto& final_checkpoint = mapCheckpoints.rbegin();
#      25                 :       1536 :         return final_checkpoint->first /* height */;
#      26                 :       1536 :     }
#      27                 :            : };
#      28                 :            : 
#      29                 :            : struct AssumeutxoHash : public BaseHash<uint256> {
#      30                 :       5040 :     explicit AssumeutxoHash(const uint256& hash) : BaseHash(hash) {}
#      31                 :            : };
#      32                 :            : 
#      33                 :            : /**
#      34                 :            :  * Holds configuration for use during UTXO snapshot load and validation. The contents
#      35                 :            :  * here are security critical, since they dictate which UTXO snapshots are recognized
#      36                 :            :  * as valid.
#      37                 :            :  */
#      38                 :            : struct AssumeutxoData {
#      39                 :            :     //! The expected hash of the deserialized UTXO set.
#      40                 :            :     const AssumeutxoHash hash_serialized;
#      41                 :            : 
#      42                 :            :     //! Used to populate the nChainTx value, which is used during BlockManager::LoadBlockIndex().
#      43                 :            :     //!
#      44                 :            :     //! We need to hardcode the value here because this is computed cumulatively using block data,
#      45                 :            :     //! which we do not necessarily have at the time of snapshot load.
#      46                 :            :     const unsigned int nChainTx;
#      47                 :            : };
#      48                 :            : 
#      49                 :            : using MapAssumeutxo = std::map<int, const AssumeutxoData>;
#      50                 :            : 
#      51                 :            : /**
#      52                 :            :  * Holds various statistics on transactions within a chain. Used to estimate
#      53                 :            :  * verification progress during chain sync.
#      54                 :            :  *
#      55                 :            :  * See also: CChainParams::TxData, GuessVerificationProgress.
#      56                 :            :  */
#      57                 :            : struct ChainTxData {
#      58                 :            :     int64_t nTime;    //!< UNIX timestamp of last known number of transactions
#      59                 :            :     int64_t nTxCount; //!< total number of transactions between genesis and that timestamp
#      60                 :            :     double dTxRate;   //!< estimated number of transactions per second after that timestamp
#      61                 :            : };
#      62                 :            : 
#      63                 :            : /**
#      64                 :            :  * CChainParams defines various tweakable parameters of a given instance of the
#      65                 :            :  * Bitcoin system.
#      66                 :            :  */
#      67                 :            : class CChainParams
#      68                 :            : {
#      69                 :            : public:
#      70                 :            :     enum Base58Type {
#      71                 :            :         PUBKEY_ADDRESS,
#      72                 :            :         SCRIPT_ADDRESS,
#      73                 :            :         SECRET_KEY,
#      74                 :            :         EXT_PUBLIC_KEY,
#      75                 :            :         EXT_SECRET_KEY,
#      76                 :            : 
#      77                 :            :         MAX_BASE58_TYPES
#      78                 :            :     };
#      79                 :            : 
#      80                 :    4909308 :     const Consensus::Params& GetConsensus() const { return consensus; }
#      81                 :     383009 :     const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
#      82                 :      17652 :     uint16_t GetDefaultPort() const { return nDefaultPort; }
#      83                 :            : 
#      84                 :       1997 :     const CBlock& GenesisBlock() const { return genesis; }
#      85                 :            :     /** Default value for -checkmempool and -checkblockindex argument */
#      86                 :       8293 :     bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
#      87                 :            :     /** Policy: Filter transactions that do not match well-defined patterns */
#      88                 :       3050 :     bool RequireStandard() const { return fRequireStandard; }
#      89                 :            :     /** If this chain is exclusively used for testing */
#      90                 :       2316 :     bool IsTestChain() const { return m_is_test_chain; }
#      91                 :            :     /** If this chain allows time to be mocked */
#      92                 :        517 :     bool IsMockableChain() const { return m_is_mockable_chain; }
#      93                 :         41 :     uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
#      94                 :            :     /** Minimum free space (in GB) needed for data directory */
#      95                 :          0 :     uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
#      96                 :            :     /** Minimum free space (in GB) needed for data directory when pruned; Does not include prune target*/
#      97                 :          0 :     uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
#      98                 :            :     /** Whether it is possible to mine blocks on demand (no retargeting) */
#      99                 :      29962 :     bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
#     100                 :            :     /** Return the network string */
#     101                 :        445 :     std::string NetworkIDString() const { return strNetworkID; }
#     102                 :            :     /** Return the list of hostnames to look up for DNS seeds */
#     103                 :          1 :     const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
#     104                 :     165916 :     const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
#     105                 :      85950 :     const std::string& Bech32HRP() const { return bech32_hrp; }
#     106                 :          3 :     const std::vector<uint8_t>& FixedSeeds() const { return vFixedSeeds; }
#     107                 :     103174 :     const CCheckpointData& Checkpoints() const { return checkpointData; }
#     108                 :            : 
#     109                 :            :     //! Get allowed assumeutxo configuration.
#     110                 :            :     //! @see ChainstateManager
#     111                 :         22 :     const MapAssumeutxo& Assumeutxo() const { return m_assumeutxo_data; }
#     112                 :            : 
#     113                 :     153051 :     const ChainTxData& TxData() const { return chainTxData; }
#     114                 :            : protected:
#     115                 :       8608 :     CChainParams() {}
#     116                 :            : 
#     117                 :            :     Consensus::Params consensus;
#     118                 :            :     CMessageHeader::MessageStartChars pchMessageStart;
#     119                 :            :     uint16_t nDefaultPort;
#     120                 :            :     uint64_t nPruneAfterHeight;
#     121                 :            :     uint64_t m_assumed_blockchain_size;
#     122                 :            :     uint64_t m_assumed_chain_state_size;
#     123                 :            :     std::vector<std::string> vSeeds;
#     124                 :            :     std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
#     125                 :            :     std::string bech32_hrp;
#     126                 :            :     std::string strNetworkID;
#     127                 :            :     CBlock genesis;
#     128                 :            :     std::vector<uint8_t> vFixedSeeds;
#     129                 :            :     bool fDefaultConsistencyChecks;
#     130                 :            :     bool fRequireStandard;
#     131                 :            :     bool m_is_test_chain;
#     132                 :            :     bool m_is_mockable_chain;
#     133                 :            :     CCheckpointData checkpointData;
#     134                 :            :     MapAssumeutxo m_assumeutxo_data;
#     135                 :            :     ChainTxData chainTxData;
#     136                 :            : };
#     137                 :            : 
#     138                 :            : /**
#     139                 :            :  * Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
#     140                 :            :  * @returns a CChainParams* of the chosen chain.
#     141                 :            :  * @throws a std::runtime_error if the chain is not supported.
#     142                 :            :  */
#     143                 :            : std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain);
#     144                 :            : 
#     145                 :            : /**
#     146                 :            :  * Return the currently selected parameters. This won't change after app
#     147                 :            :  * startup, except for unit tests.
#     148                 :            :  */
#     149                 :            : const CChainParams &Params();
#     150                 :            : 
#     151                 :            : /**
#     152                 :            :  * Sets the params returned by Params() to those for the given chain name.
#     153                 :            :  * @throws std::runtime_error when the chain is not supported.
#     154                 :            :  */
#     155                 :            : void SelectParams(const std::string& chain);
#     156                 :            : 
#     157                 :            : #endif // BITCOIN_CHAINPARAMS_H

Generated by: LCOV version 1.14