LCOV - code coverage report
Current view: top level - src - chainparamsbase.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 19 22 86.4 %
Date: 2025-02-23 09:33:43 Functions: 4 4 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2014 The Bitcoin developers
       3             : // Copyright (c) 2016-2021 The PIVX Core developers
       4             : // Distributed under the MIT software license, see the accompanying
       5             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       6             : 
       7             : #include "chainparamsbase.h"
       8             : 
       9             : #include "tinyformat.h"
      10             : #include "util/system.h"
      11             : 
      12             : #include <assert.h>
      13             : 
      14             : const std::string CBaseChainParams::MAIN = "main";
      15             : const std::string CBaseChainParams::TESTNET = "test";
      16             : const std::string CBaseChainParams::REGTEST = "regtest";
      17             : 
      18           1 : void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp)
      19             : {
      20           3 :     strUsage += HelpMessageGroup("Chain selection options:");
      21           3 :     strUsage += HelpMessageOpt("-testnet", "Use the test chain");
      22           1 :     if (debugHelp) {
      23           0 :         strUsage += HelpMessageOpt("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
      24           0 :                                                "This is intended for regression testing tools and app development.");
      25             :     }
      26           1 : }
      27             : 
      28             : static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
      29             : 
      30        1390 : const CBaseChainParams& BaseParams()
      31             : {
      32        1390 :     assert(globalChainBaseParams);
      33        1390 :     return *globalChainBaseParams;
      34             : }
      35             : 
      36         947 : std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
      37             : {
      38         947 :     if (chain == CBaseChainParams::MAIN)
      39         459 :         return std::make_unique<CBaseChainParams>("", 51473);
      40         488 :     else if (chain == CBaseChainParams::TESTNET)
      41          52 :         return std::make_unique<CBaseChainParams>("testnet5", 51475);
      42         436 :     else if (chain == CBaseChainParams::REGTEST)
      43         436 :         return std::make_unique<CBaseChainParams>("regtest", 51477);
      44             :     else
      45           0 :         throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
      46             : }
      47             : 
      48         945 : void SelectBaseParams(const std::string& chain)
      49             : {
      50        1394 :     globalChainBaseParams = CreateBaseChainParams(chain);
      51         945 :     gArgs.SelectConfigNetwork(chain);
      52         945 : }

Generated by: LCOV version 1.14