Bitcoin Core  21.99.0
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;
27  int GetHeight() const {
28  const auto& final_checkpoint = mapCheckpoints.rbegin();
29  return final_checkpoint->first /* height */;
30  }
31 };
39 struct ChainTxData {
40  int64_t nTime;
41  int64_t nTxCount;
42  double dTxRate;
43 };
53 {
54 public:
55  enum Base58Type {
63  };
65  const Consensus::Params& GetConsensus() const { return consensus; }
66  const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
67  int GetDefaultPort() const { return nDefaultPort; }
69  const CBlock& GenesisBlock() const { return genesis; }
71  bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
73  bool RequireStandard() const { return fRequireStandard; }
75  bool IsTestChain() const { return m_is_test_chain; }
77  bool IsMockableChain() const { return m_is_mockable_chain; }
78  uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
80  uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
82  uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
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<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
90  const std::string& Bech32HRP() const { return bech32_hrp; }
91  const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
92  const CCheckpointData& Checkpoints() const { return checkpointData; }
93  const ChainTxData& TxData() const { return chainTxData; }
94 protected:
103  std::vector<std::string> vSeeds;
104  std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
105  std::string bech32_hrp;
106  std::string strNetworkID;
108  std::vector<SeedSpec6> vFixedSeeds;
115 };
122 std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain);
128 const CChainParams &Params();
134 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:88
std::string NetworkIDString() const
Return the network string.
Definition: chainparams.h:86
int nDefaultPort
Definition: chainparams.h:99
double dTxRate
estimated number of transactions per second after that timestamp
Definition: chainparams.h:42
std::map< int, uint256 > MapCheckpoints
Definition: chainparams.h:22
Definition: block.h:62
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
const std::string & Bech32HRP() const
Definition: chainparams.h:90
uint64_t AssumedChainStateSize() const
Minimum free space (in GB) needed for data directory when pruned; Does not include prune target...
Definition: chainparams.h:82
int GetHeight() const
Definition: chainparams.h:27
uint64_t m_assumed_chain_state_size
Definition: chainparams.h:102
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
Definition: chainparams.h:71
const CBlock & GenesisBlock() const
Definition: chainparams.h:69
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
Definition: chainparams.h:52
std::string bech32_hrp
Definition: chainparams.h:105
CBlock genesis
Definition: chainparams.h:107
int64_t nTime
UNIX timestamp of last known number of transactions.
Definition: chainparams.h:40
const CCheckpointData & Checkpoints() const
Definition: chainparams.h:92
CMessageHeader::MessageStartChars pchMessageStart
Definition: chainparams.h:98
ChainTxData chainTxData
Definition: chainparams.h:114
uint64_t m_assumed_blockchain_size
Definition: chainparams.h:101
int64_t nTxCount
total number of transactions between genesis and that timestamp
Definition: chainparams.h:41
uint64_t PruneAfterHeight() const
Definition: chainparams.h:78
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:110
Holds various statistics on transactions within a chain.
Definition: chainparams.h:39
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:103
const CMessageHeader::MessageStartChars & MessageStart() const
Definition: chainparams.h:66
int GetDefaultPort() const
Definition: chainparams.h:67
bool m_is_mockable_chain
Definition: chainparams.h:112
Parameters that influence chain consensus.
Definition: params.h:46
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:73
const CChainParams & Params()
Return the currently selected parameters.
const ChainTxData & TxData() const
Definition: chainparams.h:93
bool IsTestChain() const
If this chain is exclusively used for testing.
Definition: chainparams.h:75
std::vector< SeedSpec6 > vFixedSeeds
Definition: chainparams.h:108
bool fRequireStandard
Definition: validation.cpp:139
uint64_t AssumedBlockchainSize() const
Minimum free space (in GB) needed for data directory.
Definition: chainparams.h:80
MapCheckpoints mapCheckpoints
Definition: chainparams.h:25
Consensus::Params consensus
Definition: chainparams.h:97
std::string strNetworkID
Definition: chainparams.h:106
const std::vector< SeedSpec6 > & FixedSeeds() const
Definition: chainparams.h:91
uint64_t nPruneAfterHeight
Definition: chainparams.h:100
bool m_is_test_chain
Definition: chainparams.h:111
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:65
uint8_t addr[16]
Definition: chainparams.h:18
CCheckpointData checkpointData
Definition: chainparams.h:113
bool IsMockableChain() const
If this chain allows time to be mocked.
Definition: chainparams.h:77
bool fDefaultConsistencyChecks
Definition: chainparams.h:109
const std::vector< unsigned char > & Base58Prefix(Base58Type type) const
Definition: chainparams.h:89