]> Git Repo - VerusCoin.git/blob - src/chainparams.h
Catch mined PoS lookalike blocks
[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 "consensus/params.h"
11 #include "primitives/block.h"
12 #include "protocol.h"
13
14 #define KOMODO_MINDIFF_NBITS 0x200f0f0f
15
16 #include <vector>
17
18 struct CDNSSeedData {
19     std::string name, host;
20     CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
21 };
22
23 struct SeedSpec6 {
24     uint8_t addr[16];
25     uint16_t port;
26 };
27
28 typedef std::map<int, uint256> MapCheckpoints;
29
30
31 /**
32  * CChainParams defines various tweakable parameters of a given instance of the
33  * Bitcoin system. There are three: the main network on which people trade goods
34  * and services, the public test network which gets reset from time to time and
35  * a regression test mode which is intended for private networks only. It has
36  * minimal difficulty to ensure that blocks can be found instantly.
37  */
38 class CChainParams
39 {
40 public:
41     enum Base58Type {
42         PUBKEY_ADDRESS,
43         SCRIPT_ADDRESS,
44         SECRET_KEY,
45         EXT_PUBLIC_KEY,
46         EXT_SECRET_KEY,
47
48         ZCPAYMENT_ADDRRESS,
49         ZCSPENDING_KEY,
50         ZCVIEWING_KEY,
51
52         MAX_BASE58_TYPES
53     };
54     struct CCheckpointData {
55         MapCheckpoints mapCheckpoints;
56         int64_t nTimeLastCheckpoint;
57         int64_t nTransactionsLastCheckpoint;
58         double fTransactionsPerDay;
59     };
60
61     const Consensus::Params& GetConsensus() const { return consensus; }
62     const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
63     const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
64     int GetDefaultPort() const { return nDefaultPort; }
65
66     const CBlock& GenesisBlock() const { return genesis; }
67     /** Make miner wait to have peers to avoid wasting work */
68     bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
69     /** Default value for -checkmempool and -checkblockindex argument */
70     bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
71     /** Policy: Filter transactions that do not match well-defined patterns */
72     bool RequireStandard() const { return fRequireStandard; }
73     int64_t MaxTipAge() const { return nMaxTipAge; }
74     int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
75     unsigned int EquihashN() const { return nEquihashN; }
76     unsigned int EquihashK() const { return nEquihashK; }
77     std::string CurrencyUnits() const { return strCurrencyUnits; }
78     /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
79     bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
80     /** In the future use NetworkIDString() for RPC fields */
81     bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
82     /** Return the BIP70 network string (main, test or regtest) */
83     std::string NetworkIDString() const { return strNetworkID; }
84     const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
85     const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
86     const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
87     const CCheckpointData& Checkpoints() const { return checkpointData; }
88     /** Return the founder's reward address and script for a given block height */
89     std::string GetFoundersRewardAddressAtHeight(int height) const;
90     CScript GetFoundersRewardScriptAtHeight(int height) const;
91     std::string GetFoundersRewardAddressAtIndex(int i) const;
92     /** Enforce coinbase consensus rule in regtest mode */
93     void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
94
95     void SetDefaultPort(uint16_t port) { nDefaultPort = port; }
96     void SetCheckpointData(CCheckpointData checkpointData);
97
98     //void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); }
99     //void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; }
100     //void setgenesis(CBlock &block) { genesis = block; }
101     //void recalc_genesis(uint32_t nonce) { genesis = CreateGenesisBlock(ASSETCHAINS_TIMESTAMP, nonce, GENESIS_NBITS, 1, COIN); };
102     int nDefaultPort = 0;
103     CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved
104     Consensus::Params consensus;
105
106 protected:
107     CChainParams() {}
108
109      //! Raw pub key bytes for the broadcast alert signing key.
110     std::vector<unsigned char> vAlertPubKey;
111     int nMinerThreads = 0;
112     long nMaxTipAge = 0;
113     uint64_t nPruneAfterHeight = 0;
114     unsigned int nEquihashN = 0;
115     unsigned int nEquihashK = 0;
116     std::vector<CDNSSeedData> vSeeds;
117     std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
118     std::string strNetworkID;
119     std::string strCurrencyUnits;
120     CBlock genesis;
121     std::vector<SeedSpec6> vFixedSeeds;
122     bool fMiningRequiresPeers = false;
123     bool fDefaultConsistencyChecks = false;
124     bool fRequireStandard = false;
125     bool fMineBlocksOnDemand = false;
126     bool fTestnetToBeDeprecatedFieldRPC = false;
127     CCheckpointData checkpointData;
128     std::vector<std::string> vFoundersRewardAddress;
129 };
130
131 /**
132  * Return the currently selected parameters. This won't change after app
133  * startup, except for unit tests.
134  */
135 const CChainParams &Params();
136
137 /** Return parameters for the given network. */
138 CChainParams &Params(CBaseChainParams::Network network);
139
140 /** Sets the params returned by Params() to those for the given network. */
141 void SelectParams(CBaseChainParams::Network network);
142
143 /**
144  * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
145  * Returns false if an invalid combination is given.
146  */
147 bool SelectParamsFromCommandLine();
148
149 /**
150  * Allows modifying the network upgrade regtest parameters.
151  */
152 void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight);
153
154 #endif // BITCOIN_CHAINPARAMS_H
This page took 0.032516 seconds and 4 git commands to generate.