LCOV - code coverage report
Current view: top level - src - chainparams.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 14 22 63.6 %
Date: 2015-10-12 22:39:14 Functions: 5 14 35.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2009-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             : #ifndef BITCOIN_CHAINPARAMS_H
       7             : #define BITCOIN_CHAINPARAMS_H
       8             : 
       9             : #include "chainparamsbase.h"
      10             : #include "consensus/params.h"
      11             : #include "primitives/block.h"
      12             : #include "protocol.h"
      13             : 
      14             : #include <vector>
      15             : 
      16       12100 : struct CDNSSeedData {
      17             :     std::string name, host;
      18        1100 :     CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
      19             : };
      20             : 
      21             : struct SeedSpec6 {
      22             :     uint8_t addr[16];
      23             :     uint16_t port;
      24             : };
      25             : 
      26             : typedef std::map<int, uint256> MapCheckpoints;
      27             : 
      28        1980 : struct CCheckpointData {
      29             :     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             :  * Bitcoin 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        2310 : class CChainParams
      43             : {
      44             : public:
      45             :     enum Base58Type {
      46             :         PUBKEY_ADDRESS,
      47             :         SCRIPT_ADDRESS,
      48             :         SECRET_KEY,
      49             :         EXT_PUBLIC_KEY,
      50             :         EXT_SECRET_KEY,
      51             : 
      52             :         MAX_BASE58_TYPES
      53             :     };
      54             : 
      55      139995 :     const Consensus::Params& GetConsensus() const { return consensus; }
      56       95683 :     const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
      57           2 :     const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
      58           0 :     int GetDefaultPort() const { return nDefaultPort; }
      59             : 
      60          61 :     const CBlock& GenesisBlock() const { return genesis; }
      61             :     /** Make miner wait to have peers to avoid wasting work */
      62           0 :     bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
      63             :     /** Default value for -checkmempool and -checkblockindex argument */
      64           0 :     bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
      65             :     /** Policy: Filter transactions that do not match well-defined patterns */
      66           0 :     bool RequireStandard() const { return fRequireStandard; }
      67           0 :     int64_t MaxTipAge() const { return nMaxTipAge; }
      68           0 :     int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
      69             :     /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
      70           0 :     bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
      71             :     /** In the future use NetworkIDString() for RPC fields */
      72           0 :     bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
      73             :     /** Return the BIP70 network string (main, test or regtest) */
      74           9 :     std::string NetworkIDString() const { return strNetworkID; }
      75          90 :     const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
      76        4475 :     const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
      77           1 :     const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
      78      189605 :     const CCheckpointData& Checkpoints() const { return checkpointData; }
      79             : protected:
      80        3630 :     CChainParams() {}
      81             : 
      82             :     Consensus::Params consensus;
      83             :     CMessageHeader::MessageStartChars pchMessageStart;
      84             :     //! Raw pub key bytes for the broadcast alert signing key.
      85             :     std::vector<unsigned char> vAlertPubKey;
      86             :     int nDefaultPort;
      87             :     long nMaxTipAge;
      88             :     uint64_t nPruneAfterHeight;
      89             :     std::vector<CDNSSeedData> vSeeds;
      90             :     std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
      91             :     std::string strNetworkID;
      92             :     CBlock genesis;
      93             :     std::vector<SeedSpec6> vFixedSeeds;
      94             :     bool fMiningRequiresPeers;
      95             :     bool fDefaultConsistencyChecks;
      96             :     bool fRequireStandard;
      97             :     bool fMineBlocksOnDemand;
      98             :     bool fTestnetToBeDeprecatedFieldRPC;
      99             :     CCheckpointData checkpointData;
     100             : };
     101             : 
     102             : /**
     103             :  * Return the currently selected parameters. This won't change after app
     104             :  * startup, except for unit tests.
     105             :  */
     106             : const CChainParams &Params();
     107             : 
     108             : /** Return parameters for the given network. */
     109             : CChainParams &Params(CBaseChainParams::Network network);
     110             : 
     111             : /** Sets the params returned by Params() to those for the given network. */
     112             : void SelectParams(CBaseChainParams::Network network);
     113             : 
     114             : /**
     115             :  * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
     116             :  * Returns false if an invalid combination is given.
     117             :  */
     118             : bool SelectParamsFromCommandLine();
     119             : 
     120             : #endif // BITCOIN_CHAINPARAMS_H

Generated by: LCOV version 1.11