Bitcoin ABC 0.30.7
P2P Digital Currency
chainparams.h
Go to the documentation of this file.
1// Copyright (c) 2010 Satoshi Nakamoto
2// Copyright (c) 2009-2021 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_KERNEL_CHAINPARAMS_H
7#define BITCOIN_KERNEL_CHAINPARAMS_H
8
9#include <consensus/params.h>
10#include <netaddress.h>
11#include <primitives/block.h>
12#include <protocol.h>
13#include <uint256.h>
14#include <util/hash_type.h>
15
16#include <cstdint>
17#include <iterator>
18#include <map>
19#include <memory>
20#include <optional>
21#include <string>
22#include <unordered_map>
23#include <utility>
24#include <vector>
25
26struct SeedSpec6 {
27 uint8_t addr[16];
28 uint16_t port;
29};
30
31typedef std::map<int, BlockHash> MapCheckpoints;
32
35};
36
37struct AssumeutxoHash : public BaseHash<uint256> {
38 explicit AssumeutxoHash(const uint256 &hash) : BaseHash(hash) {}
39};
40
49
56 const unsigned int nChainTx;
57};
58
59using MapAssumeutxo = std::map<int, const AssumeutxoData>;
60
68 int64_t nTime;
69 int64_t nTxCount;
70 double dTxRate;
71};
72
81public:
88
90 };
91
92 const Consensus::Params &GetConsensus() const { return consensus; }
95 uint16_t GetDefaultPort() const { return nDefaultPort; }
96 uint16_t GetDefaultPort(Network net) const {
97 return net == NET_I2P ? I2P_SAM31_PORT : GetDefaultPort();
98 }
99 uint16_t GetDefaultPort(const std::string &addr) const {
100 CNetAddr a;
101 return a.SetSpecial(addr) ? GetDefaultPort(a.GetNetwork())
102 : GetDefaultPort();
103 }
104
105 const CBlock &GenesisBlock() const { return genesis; }
109 bool RequireStandard() const { return fRequireStandard; }
111 bool IsTestChain() const { return m_is_test_chain; }
113 bool IsMockableChain() const { return m_is_mockable_chain; }
114 uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
121 uint64_t AssumedChainStateSize() const {
123 }
127 std::string NetworkIDString() const { return strNetworkID; }
129 const std::vector<uint8_t> &Base58Prefix(Base58Type type) const {
130 return base58Prefixes[type];
131 }
132 const std::string &CashAddrPrefix() const { return cashaddrPrefix; }
133 const std::vector<SeedSpec6> &FixedSeeds() const { return vFixedSeeds; }
134 const CCheckpointData &Checkpoints() const { return checkpointData; }
135
138 const MapAssumeutxo &Assumeutxo() const { return m_assumeutxo_data; }
139
140 const ChainTxData &TxData() const { return chainTxData; }
141
143 bool ecash{true};
144 bool fastprune{false};
145 };
146
147 static std::unique_ptr<const CChainParams>
148 RegTest(const ChainOptions &options);
149 static std::unique_ptr<const CChainParams>
150 Main(const ChainOptions &options);
151 static std::unique_ptr<const CChainParams>
152 TestNet(const ChainOptions &options);
153
154protected:
156
160 uint16_t nDefaultPort;
164 std::vector<std::string> vSeeds;
165 std::vector<uint8_t> base58Prefixes[MAX_BASE58_TYPES];
166 std::string cashaddrPrefix;
167 std::string strNetworkID;
169 std::vector<SeedSpec6> vFixedSeeds;
177
178 friend const std::vector<std::string>
179 GetRandomizedDNSSeeds(const CChainParams &params);
180};
181
182const CCheckpointData &CheckpointData(const std::string &chain);
183
184#endif // BITCOIN_KERNEL_CHAINPARAMS_H
Definition: block.h:60
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:80
uint64_t m_assumed_chain_state_size
Definition: chainparams.h:163
const CBlock & GenesisBlock() const
Definition: chainparams.h:105
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
Definition: chainparams.h:107
const CMessageHeader::MessageMagic & NetMagic() const
Definition: chainparams.h:94
const CMessageHeader::MessageMagic & DiskMagic() const
Definition: chainparams.h:93
const std::vector< SeedSpec6 > & FixedSeeds() const
Definition: chainparams.h:133
bool m_is_test_chain
Definition: chainparams.h:172
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
Definition: chainparams.h:127
CBlock genesis
Definition: chainparams.h:168
uint16_t GetDefaultPort(const std::string &addr) const
Definition: chainparams.h:99
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
Definition: chainparams.h:109
MapAssumeutxo m_assumeutxo_data
Definition: chainparams.h:175
const std::vector< uint8_t > & Base58Prefix(Base58Type type) const
Return the list of hostnames to look up for DNS seeds.
Definition: chainparams.h:129
uint64_t m_assumed_blockchain_size
Definition: chainparams.h:162
bool IsMockableChain() const
If this chain allows time to be mocked.
Definition: chainparams.h:113
CMessageHeader::MessageMagic netMagic
Definition: chainparams.h:159
std::vector< uint8_t > base58Prefixes[MAX_BASE58_TYPES]
Definition: chainparams.h:165
bool fDefaultConsistencyChecks
Definition: chainparams.h:170
std::vector< SeedSpec6 > vFixedSeeds
Definition: chainparams.h:169
const ChainTxData & TxData() const
Definition: chainparams.h:140
std::string strNetworkID
Definition: chainparams.h:167
friend const std::vector< std::string > GetRandomizedDNSSeeds(const CChainParams &params)
Return the list of hostnames to look up for DNS seeds.
Definition: dnsseeds.cpp:11
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:92
bool IsTestChain() const
If this chain is exclusively used for testing.
Definition: chainparams.h:111
bool MineBlocksOnDemand() const
Whether it is possible to mine blocks on demand (no retargeting)
Definition: chainparams.h:125
Consensus::Params consensus
Definition: chainparams.h:157
static std::unique_ptr< const CChainParams > TestNet(const ChainOptions &options)
uint16_t GetDefaultPort() const
Definition: chainparams.h:95
static std::unique_ptr< const CChainParams > RegTest(const ChainOptions &options)
const std::string & CashAddrPrefix() const
Definition: chainparams.h:132
uint64_t AssumedBlockchainSize() const
Minimum free space (in GB) needed for data directory.
Definition: chainparams.h:116
bool fRequireStandard
Definition: chainparams.h:171
std::string cashaddrPrefix
Definition: chainparams.h:166
std::vector< std::string > vSeeds
Definition: chainparams.h:164
bool m_is_mockable_chain
Definition: chainparams.h:173
CMessageHeader::MessageMagic diskMagic
Definition: chainparams.h:158
static std::unique_ptr< const CChainParams > Main(const ChainOptions &options)
uint64_t AssumedChainStateSize() const
Minimum free space (in GB) needed for data directory when pruned; Does not include prune target.
Definition: chainparams.h:121
uint64_t PruneAfterHeight() const
Definition: chainparams.h:114
CCheckpointData checkpointData
Definition: chainparams.h:174
uint16_t nDefaultPort
Definition: chainparams.h:160
const MapAssumeutxo & Assumeutxo() const
Get allowed assumeutxo configuration.
Definition: chainparams.h:138
const CCheckpointData & Checkpoints() const
Definition: chainparams.h:134
uint64_t nPruneAfterHeight
Definition: chainparams.h:161
ChainTxData chainTxData
Definition: chainparams.h:176
uint16_t GetDefaultPort(Network net) const
Definition: chainparams.h:96
std::array< uint8_t, MESSAGE_START_SIZE > MessageMagic
Definition: protocol.h:46
Network address.
Definition: netaddress.h:121
bool SetSpecial(const std::string &addr)
Parse a Tor or I2P address and set this object to it.
Definition: netaddress.cpp:227
enum Network GetNetwork() const
Definition: netaddress.cpp:549
256-bit opaque blob.
Definition: uint256.h:129
std::map< int, const AssumeutxoData > MapAssumeutxo
Definition: chainparams.h:59
std::map< int, BlockHash > MapCheckpoints
Definition: chainparams.h:31
const CCheckpointData & CheckpointData(const std::string &chain)
static constexpr uint16_t I2P_SAM31_PORT
SAM 3.1 and earlier do not support specifying ports and force the port to 0.
Definition: netaddress.h:116
Network
A network type.
Definition: netaddress.h:44
@ NET_I2P
I2P.
Definition: netaddress.h:59
Holds configuration for use during UTXO snapshot load and validation.
Definition: chainparams.h:46
const AssumeutxoHash hash_serialized
The expected hash of the deserialized UTXO set.
Definition: chainparams.h:48
const unsigned int nChainTx
Used to populate the nChainTx value, which is used during BlockManager::LoadBlockIndex().
Definition: chainparams.h:56
AssumeutxoHash(const uint256 &hash)
Definition: chainparams.h:38
MapCheckpoints mapCheckpoints
Definition: chainparams.h:34
Holds various statistics on transactions within a chain.
Definition: chainparams.h:67
double dTxRate
Definition: chainparams.h:70
int64_t nTime
Definition: chainparams.h:68
int64_t nTxCount
Definition: chainparams.h:69
Parameters that influence chain consensus.
Definition: params.h:34
bool fPowNoRetargeting
Definition: params.h:78
uint16_t port
Definition: chainparams.h:28
uint8_t addr[16]
Definition: chainparams.h:27