LCOV - code coverage report
Current view: top level - src - chainparams.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 20 21 95.2 %
Date: 2025-02-23 09:33:43 Functions: 5 6 83.3 %

          Line data    Source code
       1             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2015 The Bitcoin developers
       3             : // Copyright (c) 2014-2015 The Dash developers
       4             : // Copyright (c) 2015-2022 The PIVX Core developers
       5             : // Distributed under the MIT software license, see the accompanying
       6             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       7             : 
       8             : #ifndef PIVX_CHAINPARAMS_H
       9             : #define PIVX_CHAINPARAMS_H
      10             : 
      11             : #include "chainparamsbase.h"
      12             : #include "consensus/params.h"
      13             : #include "primitives/block.h"
      14             : #include "protocol.h"
      15             : #include "uint256.h"
      16             : 
      17             : #include <memory>
      18             : #include <vector>
      19             : 
      20        6696 : struct CDNSSeedData {
      21             :     std::string host;
      22             :     bool supportsServiceBitsFiltering;
      23        1700 :     explicit CDNSSeedData(const std::string& strHost, bool supportsServiceBitsFilteringIn = false) : host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
      24             : };
      25             : 
      26             : typedef std::map<int, uint256> MapCheckpoints;
      27             : 
      28             : struct CCheckpointData {
      29             :     const MapCheckpoints* mapCheckpoints;
      30             :     int64_t nTimeLastCheckpoint;
      31             :     int64_t nTransactionsLastCheckpoint;
      32             :     double fTransactionsPerDay;
      33             : };
      34             : 
      35             : /**
      36             :  * CChainParams defines various tweakable parameters of a given instance of the
      37             :  * PIVX system. There are three: the main network on which people trade goods
      38             :  * and services, the public test network which gets reset from time to time and
      39             :  * a regression test mode which is intended for private networks only. It has
      40             :  * minimal difficulty to ensure that blocks can be found instantly.
      41             :  */
      42             : class CChainParams
      43             : {
      44             : public:
      45       18890 :     virtual ~CChainParams() {}
      46             :     enum Base58Type {
      47             :         PUBKEY_ADDRESS,
      48             :         SCRIPT_ADDRESS,
      49             :         SECRET_KEY,     // BIP16
      50             :         EXT_PUBLIC_KEY, // BIP32
      51             :         EXT_SECRET_KEY, // BIP32
      52             :         EXT_COIN_TYPE,  // BIP44
      53             :         STAKING_ADDRESS,
      54             :         EXCHANGE_ADDRESS,
      55             : 
      56             :         MAX_BASE58_TYPES
      57             :     };
      58             : 
      59             :     enum Bech32Type {
      60             :         SAPLING_PAYMENT_ADDRESS,
      61             :         SAPLING_FULL_VIEWING_KEY,
      62             :         SAPLING_INCOMING_VIEWING_KEY,
      63             :         SAPLING_EXTENDED_SPEND_KEY,
      64             :         SAPLING_EXTENDED_FVK,
      65             : 
      66             :         BLS_SECRET_KEY,
      67             :         BLS_PUBLIC_KEY,
      68             : 
      69             :         MAX_BECH32_TYPES
      70             :     };
      71             : 
      72    14270725 :     const Consensus::Params& GetConsensus() const { return consensus; }
      73     1553496 :     const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
      74        3426 :     int GetDefaultPort() const { return nDefaultPort; }
      75             : 
      76         800 :     const CBlock& GenesisBlock() const { return genesis; }
      77             :     /** Policy: Filter transactions that do not match well-defined patterns */
      78         386 :     bool RequireStandard() const { return fRequireStandard; }
      79             :     /** How long to wait until we allow retrying of a LLMQ connection  */
      80        2113 :     int LLMQConnectionRetryTimeout() const { return nLLMQConnectionRetryTimeout; }
      81             :     /** If this chain is exclusively used for testing */
      82         475 :     bool IsTestChain() const { return IsTestnet() || IsRegTestNet(); }
      83             :     /** Make miner wait to have peers to avoid wasting work */
      84           0 :     bool MiningRequiresPeers() const { return !IsRegTestNet(); }
      85             :     /** Headers first syncing is disabled */
      86             :     bool HeadersFirstSyncingActive() const { return false; };
      87             :     /** Default value for -checkmempool and -checkblockindex argument */
      88         772 :     bool DefaultConsistencyChecks() const { return IsRegTestNet(); }
      89             : 
      90             :     /** Return the network string */
      91     2725627 :     std::string NetworkIDString() const { return strNetworkID; }
      92         355 :     const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
      93     2002160 :     const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
      94       32090 :     const std::string& Bech32HRP(Bech32Type type) const { return bech32HRPs[type]; }
      95         121 :     const std::vector<uint8_t>& FixedSeeds() const { return vFixedSeeds; }
      96             :     virtual const CCheckpointData& Checkpoints() const = 0;
      97             : 
      98     1754038 :     bool IsRegTestNet() const { return NetworkIDString() == CBaseChainParams::REGTEST; }
      99      288933 :     bool IsTestnet() const { return NetworkIDString() == CBaseChainParams::TESTNET; }
     100             : 
     101             :     /** Tier two requests blockage mark expiration time */
     102        1485 :     int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
     103             : 
     104             :     void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight);
     105             : protected:
     106       16272 :     CChainParams() {}
     107             : 
     108             :     std::string strNetworkID;
     109             :     CBlock genesis;
     110             :     Consensus::Params consensus;
     111             :     CMessageHeader::MessageStartChars pchMessageStart;
     112             :     int nDefaultPort;
     113             :     std::vector<CDNSSeedData> vSeeds;
     114             :     std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
     115             :     std::string bech32HRPs[MAX_BECH32_TYPES];
     116             :     std::vector<uint8_t> vFixedSeeds;
     117             :     bool fRequireStandard;
     118             : 
     119             :     // Tier two
     120             :     int nLLMQConnectionRetryTimeout;
     121             :     int nFulfilledRequestExpireTime;
     122             : };
     123             : 
     124             : /**
     125             :  * Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
     126             :  * @returns a CChainParams* of the chosen chain.
     127             :  * @throws a std::runtime_error if the chain is not supported.
     128             :  */
     129             : std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain);
     130             : 
     131             : /**
     132             :  * Return the currently selected parameters. This won't change after app
     133             :  * startup, except for unit tests.
     134             :  */
     135             : const CChainParams& Params();
     136             : 
     137             : /**
     138             :  * Sets the params returned by Params() to those for the given chain name.
     139             :  * @throws std::runtime_error when the chain is not supported.
     140             :  */
     141             : void SelectParams(const std::string& chain);
     142             : 
     143             : /**
     144             :  * Allows modifying the network upgrade regtest parameters.
     145             :  */
     146             : void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight);
     147             : 
     148             : #endif // PIVX_CHAINPARAMS_H

Generated by: LCOV version 1.14