Bitcoin ABC  0.22.13
P2P Digital Currency
chainparams.h
Go to the documentation of this file.
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.
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 #include <memory>
15 #include <vector>
16 
17 struct SeedSpec6 {
18  uint8_t addr[16];
19  uint16_t port;
20 };
21 
22 typedef std::map<int, BlockHash> MapCheckpoints;
23 
26 };
27 
34 struct ChainTxData {
35  int64_t nTime;
36  int64_t nTxCount;
37  double dTxRate;
38 };
39 
47 class CChainParams {
48 public:
49  enum Base58Type {
55 
56  MAX_BASE58_TYPES
57  };
58 
59  const Consensus::Params &GetConsensus() const { return consensus; }
60  const CMessageHeader::MessageMagic &DiskMagic() const { return diskMagic; }
61  const CMessageHeader::MessageMagic &NetMagic() const { return netMagic; }
62  int GetDefaultPort() const { return nDefaultPort; }
63 
64  const CBlock &GenesisBlock() const { return genesis; }
66  bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
68  bool RequireStandard() const { return fRequireStandard; }
70  bool IsTestChain() const { return m_is_test_chain; }
72  bool IsMockableChain() const { return m_is_mockable_chain; }
73  uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
75  uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
80  uint64_t AssumedChainStateSize() const {
81  return m_assumed_chain_state_size;
82  }
84  bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
86  std::string NetworkIDString() const { return strNetworkID; }
88  const std::vector<std::string> &DNSSeeds() const { return vSeeds; }
89  const std::vector<uint8_t> &Base58Prefix(Base58Type type) const {
90  return base58Prefixes[type];
91  }
92  const std::string &CashAddrPrefix() const { return cashaddrPrefix; }
93  const std::vector<SeedSpec6> &FixedSeeds() const { return vFixedSeeds; }
94  const CCheckpointData &Checkpoints() const { return checkpointData; }
95  const ChainTxData &TxData() const { return chainTxData; }
96 
97 protected:
99 
107  std::vector<std::string> vSeeds;
108  std::vector<uint8_t> base58Prefixes[MAX_BASE58_TYPES];
109  std::string cashaddrPrefix;
110  std::string strNetworkID;
112  std::vector<SeedSpec6> vFixedSeeds;
119 };
120 
126 std::unique_ptr<CChainParams> CreateChainParams(const std::string &chain);
127 
128 CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits,
129  int32_t nVersion, const Amount genesisReward);
130 
135 const CChainParams &Params();
136 
141 void SelectParams(const std::string &chain);
142 
143 const CCheckpointData &CheckpointData(const std::string &chain);
144 
145 #endif // BITCOIN_CHAINPARAMS_H
const std::vector< std::string > & DNSSeeds() const
Return the list of hostnames to look up for DNS seeds.
Definition: chainparams.h:88
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
Definition: chainparams.h:86
double dTxRate
Definition: chainparams.h:37
Definition: block.h:62
uint64_t AssumedChainStateSize() const
Minimum free space (in GB) needed for data directory when pruned; Does not include prune target...
Definition: chainparams.h:80
Definition: amount.h:17
const CMessageHeader::MessageMagic & DiskMagic() const
Definition: chainparams.h:60
uint64_t m_assumed_chain_state_size
Definition: chainparams.h:106
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
Definition: chainparams.h:66
const CBlock & GenesisBlock() const
Definition: chainparams.h:64
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
Definition: chainparams.h:47
const CCheckpointData & CheckpointData(const std::string &chain)
Definition: checkpoints.cpp:99
CBlock genesis
Definition: chainparams.h:111
int64_t nTime
Definition: chainparams.h:35
const CCheckpointData & Checkpoints() const
Definition: chainparams.h:94
ChainTxData chainTxData
Definition: chainparams.h:118
uint64_t m_assumed_blockchain_size
Definition: chainparams.h:105
int64_t nTxCount
Definition: chainparams.h:36
uint64_t PruneAfterHeight() const
Definition: chainparams.h:73
uint16_t port
Definition: chainparams.h:19
bool MineBlocksOnDemand() const
Whether it is possible to mine blocks on demand (no retargeting)
Definition: chainparams.h:84
bool fRequireStandard
Definition: chainparams.h:114
CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const Amount genesisReward)
Build the genesis block.
Definition: chainparams.cpp:60
Holds various statistics on transactions within a chain.
Definition: chainparams.h:34
void SelectParams(const std::string &chain)
Sets the params returned by Params() to those for the given BIP70 chain name.
std::vector< std::string > vSeeds
Definition: chainparams.h:107
int GetDefaultPort() const
Definition: chainparams.h:62
bool m_is_mockable_chain
Definition: chainparams.h:116
Parameters that influence chain consensus.
Definition: params.h:59
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
Definition: chainparams.h:68
const CChainParams & Params()
Return the currently selected parameters.
const ChainTxData & TxData() const
Definition: chainparams.h:95
bool IsTestChain() const
If this chain is exclusively used for testing.
Definition: chainparams.h:70
std::vector< SeedSpec6 > vFixedSeeds
Definition: chainparams.h:112
bool fRequireStandard
Definition: validation.cpp:105
uint64_t AssumedBlockchainSize() const
Minimum free space (in GB) needed for data directory.
Definition: chainparams.h:75
MapCheckpoints mapCheckpoints
Definition: chainparams.h:25
std::array< uint8_t, MESSAGE_START_SIZE > MessageMagic
Definition: protocol.h:49
Consensus::Params consensus
Definition: chainparams.h:100
std::map< int, BlockHash > MapCheckpoints
Definition: chainparams.h:22
std::string strNetworkID
Definition: chainparams.h:110
const std::vector< SeedSpec6 > & FixedSeeds() const
Definition: chainparams.h:93
CMessageHeader::MessageMagic diskMagic
Definition: chainparams.h:101
const std::string & CashAddrPrefix() const
Definition: chainparams.h:92
uint64_t nPruneAfterHeight
Definition: chainparams.h:104
const std::vector< uint8_t > & Base58Prefix(Base58Type type) const
Definition: chainparams.h:89
bool m_is_test_chain
Definition: chainparams.h:115
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:59
uint8_t addr[16]
Definition: chainparams.h:18
CCheckpointData checkpointData
Definition: chainparams.h:117
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
CMessageHeader::MessageMagic netMagic
Definition: chainparams.h:102
bool IsMockableChain() const
If this chain allows time to be mocked.
Definition: chainparams.h:72
std::string cashaddrPrefix
Definition: chainparams.h:109
const CMessageHeader::MessageMagic & NetMagic() const
Definition: chainparams.h:61
bool fDefaultConsistencyChecks
Definition: chainparams.h:113