]> Git Repo - VerusCoin.git/blob - src/chainparams.h
Merge commit 'adae78ea9940f4d44382967d1296e7db0b54a4de' into leveldb-squashed
[VerusCoin.git] / src / chainparams.h
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2013 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6 #ifndef BITCOIN_CHAIN_PARAMS_H
7 #define BITCOIN_CHAIN_PARAMS_H
8
9 #include "bignum.h"
10 #include "uint256.h"
11 #include "util.h"
12
13 #include <vector>
14
15 using namespace std;
16
17 #define MESSAGE_START_SIZE 4
18 typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];
19
20 class CAddress;
21 class CBlock;
22
23 struct CDNSSeedData {
24     string name, host;
25     CDNSSeedData(const string &strName, const string &strHost) : name(strName), host(strHost) {}
26 };
27
28 /**
29  * CChainParams defines various tweakable parameters of a given instance of the
30  * Bitcoin system. There are three: the main network on which people trade goods
31  * and services, the public test network which gets reset from time to time and
32  * a regression test mode which is intended for private networks only. It has
33  * minimal difficulty to ensure that blocks can be found instantly.
34  */
35 class CChainParams
36 {
37 public:
38     enum Network {
39         MAIN,
40         TESTNET,
41         REGTEST,
42     };
43
44     enum Base58Type {
45         PUBKEY_ADDRESS,
46         SCRIPT_ADDRESS,
47         SECRET_KEY,
48
49         MAX_BASE58_TYPES
50     };
51
52     const uint256& HashGenesisBlock() const { return hashGenesisBlock; }
53     const MessageStartChars& MessageStart() const { return pchMessageStart; }
54     const vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
55     int GetDefaultPort() const { return nDefaultPort; }
56     const CBigNum& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
57     int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; }
58     virtual const CBlock& GenesisBlock() const = 0;
59     virtual bool RequireRPCPassword() const { return true; }
60     const string& DataDir() const { return strDataDir; }
61     virtual Network NetworkID() const = 0;
62     const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
63     int Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
64     virtual const vector<CAddress>& FixedSeeds() const = 0;
65     int RPCPort() const { return nRPCPort; }
66 protected:
67     CChainParams() {};
68
69     uint256 hashGenesisBlock;
70     MessageStartChars pchMessageStart;
71     // Raw pub key bytes for the broadcast alert signing key.
72     vector<unsigned char> vAlertPubKey;
73     int nDefaultPort;
74     int nRPCPort;
75     CBigNum bnProofOfWorkLimit;
76     int nSubsidyHalvingInterval;
77     string strDataDir;
78     vector<CDNSSeedData> vSeeds;
79     int base58Prefixes[MAX_BASE58_TYPES];
80 };
81
82 /**
83  * Return the currently selected parameters. This won't change after app startup
84  * outside of the unit tests.
85  */
86 const CChainParams &Params();
87
88 /** Sets the params returned by Params() to those for the given network. */
89 void SelectParams(CChainParams::Network network);
90
91 /**
92  * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
93  * Returns false if an invalid combination is given.
94  */
95 bool SelectParamsFromCommandLine();
96
97 inline bool TestNet() {
98     // Note: it's deliberate that this returns "false" for regression test mode.
99     return Params().NetworkID() == CChainParams::TESTNET;
100 }
101
102 #endif
This page took 0.029427 seconds and 4 git commands to generate.