LCOV - code coverage report
Current view: top level - src - chainparamsbase.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 27 28 96.4 %
Date: 2020-09-26 01:30:44 Functions: 8 8 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2019 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             : #include <chainparamsbase.h>
       7             : 
       8             : #include <tinyformat.h>
       9             : #include <util/system.h>
      10             : #include <util/memory.h>
      11             : 
      12             : #include <assert.h>
      13             : 
      14        1150 : const std::string CBaseChainParams::MAIN = "main";
      15        1150 : const std::string CBaseChainParams::TESTNET = "test";
      16        1150 : const std::string CBaseChainParams::REGTEST = "regtest";
      17             : 
      18        1520 : void SetupChainParamsBaseOptions(ArgsManager& argsman)
      19             : {
      20        1520 :     argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
      21        1520 :     argsman.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
      22        1520 :                  "This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
      23        1520 :     argsman.AddArg("-segwitheight=<n>", "Set the activation height of segwit. -1 to disable. (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
      24        1520 :     argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
      25        1520 :     argsman.AddArg("-vbparams=deployment:start:end", "Use given start/end times for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
      26        1520 : }
      27             : 
      28        1150 : static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
      29             : 
      30        3375 : const CBaseChainParams& BaseParams()
      31             : {
      32        3375 :     assert(globalChainBaseParams);
      33        3375 :     return *globalChainBaseParams;
      34             : }
      35             : 
      36        6098 : std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
      37             : {
      38        6098 :     if (chain == CBaseChainParams::MAIN)
      39        2053 :         return MakeUnique<CBaseChainParams>("", 8332);
      40        4045 :     else if (chain == CBaseChainParams::TESTNET)
      41        1544 :         return MakeUnique<CBaseChainParams>("testnet3", 18332);
      42        2501 :     else if (chain == CBaseChainParams::REGTEST)
      43        2501 :         return MakeUnique<CBaseChainParams>("regtest", 18443);
      44             :     else
      45           0 :         throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
      46        6098 : }
      47             : 
      48        1811 : void SelectBaseParams(const std::string& chain)
      49             : {
      50        1811 :     globalChainBaseParams = CreateBaseChainParams(chain);
      51        1811 :     gArgs.SelectConfigNetwork(chain);
      52        1811 : }

Generated by: LCOV version 1.15