[wallet] Don't hold cs_LastBlockFile while calling setBestChain
[bitcoinplatinum.git] / src / chainparams.h
blobf55ae4cf7f068f8884f976c7a6c431bb7a778bcb
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 <memory>
15 #include <vector>
17 struct CDNSSeedData {
18 std::string host;
19 bool supportsServiceBitsFiltering;
20 CDNSSeedData(const std::string &strHost, bool supportsServiceBitsFilteringIn) : host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
23 struct SeedSpec6 {
24 uint8_t addr[16];
25 uint16_t port;
28 typedef std::map<int, uint256> MapCheckpoints;
30 struct CCheckpointData {
31 MapCheckpoints mapCheckpoints;
34 struct ChainTxData {
35 int64_t nTime;
36 int64_t nTxCount;
37 double dTxRate;
40 /**
41 * CChainParams defines various tweakable parameters of a given instance of the
42 * Bitcoin system. There are three: the main network on which people trade goods
43 * and services, the public test network which gets reset from time to time and
44 * a regression test mode which is intended for private networks only. It has
45 * minimal difficulty to ensure that blocks can be found instantly.
47 class CChainParams
49 public:
50 enum Base58Type {
51 PUBKEY_ADDRESS,
52 SCRIPT_ADDRESS,
53 SECRET_KEY,
54 EXT_PUBLIC_KEY,
55 EXT_SECRET_KEY,
57 MAX_BASE58_TYPES
60 const Consensus::Params& GetConsensus() const { return consensus; }
61 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
62 int GetDefaultPort() const { return nDefaultPort; }
64 const CBlock& GenesisBlock() const { return genesis; }
65 /** Default value for -checkmempool and -checkblockindex argument */
66 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
67 /** Policy: Filter transactions that do not match well-defined patterns */
68 bool RequireStandard() const { return fRequireStandard; }
69 uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
70 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
71 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
72 /** Return the BIP70 network string (main, test or regtest) */
73 std::string NetworkIDString() const { return strNetworkID; }
74 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
75 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
76 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
77 const CCheckpointData& Checkpoints() const { return checkpointData; }
78 const ChainTxData& TxData() const { return chainTxData; }
79 void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
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 fDefaultConsistencyChecks;
93 bool fRequireStandard;
94 bool fMineBlocksOnDemand;
95 CCheckpointData checkpointData;
96 ChainTxData chainTxData;
99 /**
100 * Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
101 * @returns a CChainParams* of the chosen chain.
102 * @throws a std::runtime_error if the chain is not supported.
104 std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain);
107 * Return the currently selected parameters. This won't change after app
108 * startup, except for unit tests.
110 const CChainParams &Params();
113 * Sets the params returned by Params() to those for the given BIP70 chain name.
114 * @throws std::runtime_error when the chain is not supported.
116 void SelectParams(const std::string& chain);
119 * Allows modifying the Version Bits regtest parameters.
121 void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
123 #endif // BITCOIN_CHAINPARAMS_H