]> Git Repo - VerusCoin.git/blob - src/chainparams.h
Chainparams: Refactor: Remove redundant AllowMinDifficultyBlocks() getter
[VerusCoin.git] / src / chainparams.h
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 "checkpoints.h"
11 #include "consensus/params.h"
12 #include "primitives/block.h"
13 #include "protocol.h"
14
15 #include <vector>
16
17 struct CDNSSeedData {
18     std::string name, host;
19     CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
20 };
21
22 /**
23  * CChainParams defines various tweakable parameters of a given instance of the
24  * Bitcoin system. There are three: the main network on which people trade goods
25  * and services, the public test network which gets reset from time to time and
26  * a regression test mode which is intended for private networks only. It has
27  * minimal difficulty to ensure that blocks can be found instantly.
28  */
29 class CChainParams
30 {
31 public:
32     enum Base58Type {
33         PUBKEY_ADDRESS,
34         SCRIPT_ADDRESS,
35         SECRET_KEY,
36         EXT_PUBLIC_KEY,
37         EXT_SECRET_KEY,
38
39         MAX_BASE58_TYPES
40     };
41
42     const Consensus::Params& GetConsensus() const { return consensus; }
43     const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
44     const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
45     int GetDefaultPort() const { return nDefaultPort; }
46     int SubsidyHalvingInterval() const { return consensus.nSubsidyHalvingInterval; }
47     int EnforceBlockUpgradeMajority() const { return consensus.nMajorityEnforceBlockUpgrade; }
48     int RejectBlockOutdatedMajority() const { return consensus.nMajorityRejectBlockOutdated; }
49     int ToCheckBlockUpgradeMajority() const { return consensus.nMajorityWindow; }
50
51     /** Used if GenerateBitcoins is called with a negative number of threads */
52     int DefaultMinerThreads() const { return nMinerThreads; }
53     const CBlock& GenesisBlock() const { return genesis; }
54     bool RequireRPCPassword() const { return fRequireRPCPassword; }
55     /** Make miner wait to have peers to avoid wasting work */
56     bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
57     /** Default value for -checkmempool and -checkblockindex argument */
58     bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
59     /** Make standard checks */
60     bool RequireStandard() const { return fRequireStandard; }
61     /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
62     bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
63     /** In the future use NetworkIDString() for RPC fields */
64     bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
65     /** Return the BIP70 network string (main, test or regtest) */
66     std::string NetworkIDString() const { return strNetworkID; }
67     const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
68     const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
69     const std::vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
70     virtual const Checkpoints::CCheckpointData& Checkpoints() const = 0;
71 protected:
72     CChainParams() {}
73
74     Consensus::Params consensus;
75     CMessageHeader::MessageStartChars pchMessageStart;
76     //! Raw pub key bytes for the broadcast alert signing key.
77     std::vector<unsigned char> vAlertPubKey;
78     int nDefaultPort;
79     int nMinerThreads;
80     std::vector<CDNSSeedData> vSeeds;
81     std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
82     std::string strNetworkID;
83     CBlock genesis;
84     std::vector<CAddress> vFixedSeeds;
85     bool fRequireRPCPassword;
86     bool fMiningRequiresPeers;
87     bool fDefaultConsistencyChecks;
88     bool fRequireStandard;
89     bool fMineBlocksOnDemand;
90     bool fTestnetToBeDeprecatedFieldRPC;
91 };
92
93 /**
94  * Return the currently selected parameters. This won't change after app startup
95  * outside of the unit tests.
96  */
97 const CChainParams &Params();
98
99 /** Return parameters for the given network. */
100 CChainParams &Params(CBaseChainParams::Network network);
101
102 /** Sets the params returned by Params() to those for the given network. */
103 void SelectParams(CBaseChainParams::Network network);
104
105 /**
106  * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
107  * Returns false if an invalid combination is given.
108  */
109 bool SelectParamsFromCommandLine();
110
111 #endif // BITCOIN_CHAINPARAMS_H
This page took 0.031153 seconds and 4 git commands to generate.