don't throw std::bad_alloc when out of memory. Instead, terminate immediately
[bitcoinplatinum.git] / src / chainparams.h
blobdb524e8f8edfe013ea1ccaae6c9ac8bc9b741ea4
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 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.
6 #ifndef BITCOIN_CHAINPARAMS_H
7 #define BITCOIN_CHAINPARAMS_H
9 #include "chainparamsbase.h"
10 #include "consensus/params.h"
11 #include "primitives/block.h"
12 #include "protocol.h"
14 #include <vector>
16 struct CDNSSeedData {
17 std::string name, host;
18 bool supportsServiceBitsFiltering;
19 CDNSSeedData(const std::string &strName, const std::string &strHost, bool supportsServiceBitsFilteringIn = false) : name(strName), host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
22 struct SeedSpec6 {
23 uint8_t addr[16];
24 uint16_t port;
27 typedef std::map<int, uint256> MapCheckpoints;
29 struct CCheckpointData {
30 MapCheckpoints mapCheckpoints;
33 struct ChainTxData {
34 int64_t nTime;
35 int64_t nTxCount;
36 double dTxRate;
39 /**
40 * CChainParams defines various tweakable parameters of a given instance of the
41 * Bitcoin system. There are three: the main network on which people trade goods
42 * and services, the public test network which gets reset from time to time and
43 * a regression test mode which is intended for private networks only. It has
44 * minimal difficulty to ensure that blocks can be found instantly.
46 class CChainParams
48 public:
49 enum Base58Type {
50 PUBKEY_ADDRESS,
51 SCRIPT_ADDRESS,
52 SECRET_KEY,
53 EXT_PUBLIC_KEY,
54 EXT_SECRET_KEY,
56 MAX_BASE58_TYPES
59 const Consensus::Params& GetConsensus() const { return consensus; }
60 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
61 int GetDefaultPort() const { return nDefaultPort; }
63 const CBlock& GenesisBlock() const { return genesis; }
64 /** Make miner wait to have peers to avoid wasting work */
65 bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
66 /** Default value for -checkmempool and -checkblockindex argument */
67 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
68 /** Policy: Filter transactions that do not match well-defined patterns */
69 bool RequireStandard() const { return fRequireStandard; }
70 uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
71 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
72 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
73 /** Return the BIP70 network string (main, test or regtest) */
74 std::string NetworkIDString() const { return strNetworkID; }
75 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
76 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
77 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
78 const CCheckpointData& Checkpoints() const { return checkpointData; }
79 const ChainTxData& TxData() const { return chainTxData; }
80 protected:
81 CChainParams() {}
83 Consensus::Params consensus;
84 CMessageHeader::MessageStartChars pchMessageStart;
85 int nDefaultPort;
86 uint64_t nPruneAfterHeight;
87 std::vector<CDNSSeedData> vSeeds;
88 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
89 std::string strNetworkID;
90 CBlock genesis;
91 std::vector<SeedSpec6> vFixedSeeds;
92 bool fMiningRequiresPeers;
93 bool fDefaultConsistencyChecks;
94 bool fRequireStandard;
95 bool fMineBlocksOnDemand;
96 CCheckpointData checkpointData;
97 ChainTxData chainTxData;
101 * Return the currently selected parameters. This won't change after app
102 * startup, except for unit tests.
104 const CChainParams &Params();
107 * @returns CChainParams for the given BIP70 chain name.
109 CChainParams& Params(const std::string& chain);
112 * Sets the params returned by Params() to those for the given BIP70 chain name.
113 * @throws std::runtime_error when the chain is not supported.
115 void SelectParams(const std::string& chain);
118 * Allows modifying the BIP9 regtest parameters.
120 void UpdateRegtestBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
122 #endif // BITCOIN_CHAINPARAMS_H