Bitcoin Core  0.20.99
P2P Digital Currency
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2020 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or
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 SeedSpec6 {
18  uint8_t addr[16];
19  uint16_t port;
20 };
22 typedef std::map<int, uint256> MapCheckpoints;
26 };
34 struct ChainTxData {
35  int64_t nTime;
36  int64_t nTxCount;
37  double dTxRate;
38 };
48 {
49 public:
50  enum Base58Type {
58  };
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; }
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; }
77  uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
79  bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
81  std::string NetworkIDString() const { return strNetworkID; }
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:
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 };
117 std::unique_ptr<const CChainParams> CreateChainParams(const std::string& chain);
123 const CChainParams &Params();
129 void SelectParams(const std::string& chain);
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 network string.
Definition: chainparams.h:81
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:62
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:77
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:109
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: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:79
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 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
bool m_is_mockable_chain
Definition: chainparams.h:107
Parameters that influence chain consensus.
Definition: params.h:45
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 chain is exclusively used for testing.
Definition: chainparams.h:70
std::vector< SeedSpec6 > vFixedSeeds
Definition: chainparams.h:103
bool fRequireStandard
Definition: validation.cpp:139
uint64_t AssumedBlockchainSize() const
Minimum free space (in GB) needed for data directory.
Definition: chainparams.h:75
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 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:108
bool IsMockableChain() const
If this chain allows time to be mocked.
Definition: chainparams.h:72
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