Bitcoin Core  0.18.99
P2P Digital Currency
chainparams.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2018 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, uint256> MapCheckpoints;
23 
26 };
27 
34 struct ChainTxData {
35  int64_t nTime;
36  int64_t nTxCount;
37  double dTxRate;
38 };
39 
48 {
49 public:
50  enum Base58Type {
56 
57  MAX_BASE58_TYPES
58  };
59 
60  const Consensus::Params& GetConsensus() const { return consensus; }
61  const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
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; }
71  uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
73  uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
75  uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
77  bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
79  std::string NetworkIDString() const { return strNetworkID; }
81  bool IsFallbackFeeEnabled() const { return m_fallback_fee_enabled; }
83  const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
84  const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
85  const std::string& Bech32HRP() const { return bech32_hrp; }
86  const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
87  const CCheckpointData& Checkpoints() const { return checkpointData; }
88  const ChainTxData& TxData() const { return chainTxData; }
89 protected:
91 
98  std::vector<std::string> vSeeds;
99  std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
100  std::string bech32_hrp;
101  std::string strNetworkID;
103  std::vector<SeedSpec6> vFixedSeeds;
110 };
111 
117 std::unique_ptr<const CChainParams> CreateChainParams(const std::string& chain);
118 
123 const CChainParams &Params();
124 
129 void SelectParams(const std::string& chain);
130 
131 #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:83
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
Definition: chainparams.h:79
int nDefaultPort
Definition: chainparams.h:94
double dTxRate
estimated number of transactions per second after that timestamp
Definition: chainparams.h:37
std::map< int, uint256 > MapCheckpoints
Definition: chainparams.h:22
Definition: block.h:72
const std::string & Bech32HRP() const
Definition: chainparams.h:85
uint64_t AssumedChainStateSize() const
Minimum free space (in GB) needed for data directory when pruned; Does not include prune target...
Definition: chainparams.h:75
uint64_t m_assumed_chain_state_size
Definition: chainparams.h:97
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
std::string bech32_hrp
Definition: chainparams.h:100
CBlock genesis
Definition: chainparams.h:102
int64_t nTime
UNIX timestamp of last known number of transactions.
Definition: chainparams.h:35
const CCheckpointData & Checkpoints() const
Definition: chainparams.h:87
CMessageHeader::MessageStartChars pchMessageStart
Definition: chainparams.h:93
ChainTxData chainTxData
Definition: chainparams.h:108
uint64_t m_assumed_blockchain_size
Definition: chainparams.h:96
int64_t nTxCount
total number of transactions between genesis and that timestamp
Definition: chainparams.h:36
uint64_t PruneAfterHeight() const
Definition: chainparams.h:71
uint16_t port
Definition: chainparams.h:19
bool m_fallback_fee_enabled
Definition: chainparams.h:109
bool MineBlocksOnDemand() const
Whether it is possible to mine blocks on demand (no retargeting)
Definition: chainparams.h:77
bool fRequireStandard
Definition: chainparams.h:105
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:98
const CMessageHeader::MessageStartChars & MessageStart() const
Definition: chainparams.h:61
int GetDefaultPort() const
Definition: chainparams.h:62
Parameters that influence chain consensus.
Definition: params.h:49
unsigned char MessageStartChars[MESSAGE_START_SIZE]
Definition: protocol.h:38
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:88
bool IsTestChain() const
If this is a test chain.
Definition: chainparams.h:70
std::vector< SeedSpec6 > vFixedSeeds
Definition: chainparams.h:103
bool fRequireStandard
Definition: validation.cpp:111
uint64_t AssumedBlockchainSize() const
Minimum free space (in GB) needed for data directory.
Definition: chainparams.h:73
MapCheckpoints mapCheckpoints
Definition: chainparams.h:25
Consensus::Params consensus
Definition: chainparams.h:92
std::string strNetworkID
Definition: chainparams.h:101
const std::vector< SeedSpec6 > & FixedSeeds() const
Definition: chainparams.h:86
uint64_t nPruneAfterHeight
Definition: chainparams.h:95
bool IsFallbackFeeEnabled() const
Return true if the fallback fee is by default enabled for this network.
Definition: chainparams.h:81
bool m_is_test_chain
Definition: chainparams.h:106
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:60
uint8_t addr[16]
Definition: chainparams.h:18
CCheckpointData checkpointData
Definition: chainparams.h:107
std::unique_ptr< const CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
bool fDefaultConsistencyChecks
Definition: chainparams.h:104
const std::vector< unsigned char > & Base58Prefix(Base58Type type) const
Definition: chainparams.h:84