LCOV - code coverage report
Current view: top level - src - chainparams.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 28 31 90.3 %
Date: 2022-04-21 14:51:19 Functions: 22 23 95.7 %
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: 1 4 25.0 %

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

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