LCOV - code coverage report
Current view: top level - src - chainparamsbase.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 49 54 90.7 %
Date: 2015-10-12 22:39:14 Functions: 13 14 92.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2014 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 "util.h"
       9             : 
      10             : #include <assert.h>
      11             : 
      12             : /**
      13             :  * Main network
      14             :  */
      15         406 : class CBaseMainParams : public CBaseChainParams
      16             : {
      17             : public:
      18           0 :     CBaseMainParams()
      19         406 :     {
      20         406 :         nRPCPort = 8332;
      21           0 :     }
      22             : };
      23         203 : static CBaseMainParams mainParams;
      24             : 
      25             : /**
      26             :  * Testnet (v3)
      27             :  */
      28         406 : class CBaseTestNetParams : public CBaseChainParams
      29             : {
      30             : public:
      31         203 :     CBaseTestNetParams()
      32         203 :     {
      33         203 :         nRPCPort = 18332;
      34         203 :         strDataDir = "testnet3";
      35         203 :     }
      36             : };
      37         203 : static CBaseTestNetParams testNetParams;
      38             : 
      39             : /*
      40             :  * Regression test
      41             :  */
      42         406 : class CBaseRegTestParams : public CBaseChainParams
      43             : {
      44             : public:
      45         203 :     CBaseRegTestParams()
      46         203 :     {
      47         203 :         nRPCPort = 18332;
      48         203 :         strDataDir = "regtest";
      49         203 :     }
      50             : };
      51         203 : static CBaseRegTestParams regTestParams;
      52             : 
      53             : /*
      54             :  * Unit test
      55             :  */
      56         406 : class CBaseUnitTestParams : public CBaseMainParams
      57             : {
      58             : public:
      59         203 :     CBaseUnitTestParams()
      60         203 :     {
      61         203 :         strDataDir = "unittest";
      62         203 :     }
      63             : };
      64         203 : static CBaseUnitTestParams unitTestParams;
      65             : 
      66             : static CBaseChainParams* pCurrentBaseParams = 0;
      67             : 
      68         400 : const CBaseChainParams& BaseParams()
      69             : {
      70         400 :     assert(pCurrentBaseParams);
      71         400 :     return *pCurrentBaseParams;
      72             : }
      73             : 
      74         484 : void SelectBaseParams(CBaseChainParams::Network network)
      75             : {
      76         484 :     switch (network) {
      77             :     case CBaseChainParams::MAIN:
      78         248 :         pCurrentBaseParams = &mainParams;
      79         248 :         break;
      80             :     case CBaseChainParams::TESTNET:
      81          48 :         pCurrentBaseParams = &testNetParams;
      82          48 :         break;
      83             :     case CBaseChainParams::REGTEST:
      84         188 :         pCurrentBaseParams = &regTestParams;
      85         188 :         break;
      86             :     default:
      87           0 :         assert(false && "Unimplemented network");
      88             :         return;
      89             :     }
      90         484 : }
      91             : 
      92         201 : CBaseChainParams::Network NetworkIdFromCommandLine()
      93             : {
      94         603 :     bool fRegTest = GetBoolArg("-regtest", false);
      95         603 :     bool fTestNet = GetBoolArg("-testnet", false);
      96             : 
      97         201 :     if (fTestNet && fRegTest)
      98             :         return CBaseChainParams::MAX_NETWORK_TYPES;
      99         201 :     if (fRegTest)
     100             :         return CBaseChainParams::REGTEST;
     101          14 :     if (fTestNet)
     102             :         return CBaseChainParams::TESTNET;
     103          14 :     return CBaseChainParams::MAIN;
     104             : }
     105             : 
     106          93 : bool SelectBaseParamsFromCommandLine()
     107             : {
     108          93 :     CBaseChainParams::Network network = NetworkIdFromCommandLine();
     109          93 :     if (network == CBaseChainParams::MAX_NETWORK_TYPES)
     110             :         return false;
     111             : 
     112          93 :     SelectBaseParams(network);
     113          93 :     return true;
     114             : }
     115             : 
     116           0 : bool AreBaseParamsConfigured()
     117             : {
     118           0 :     return pCurrentBaseParams != NULL;
     119         609 : }

Generated by: LCOV version 1.11