|
6 | 6 | #ifndef BITCOIN_CHAINPARAMS_H
|
7 | 7 | #define BITCOIN_CHAINPARAMS_H
|
8 | 8 |
|
| 9 | +#include <kernel/chainparams.h> |
| 10 | + |
9 | 11 | #include <chainparamsbase.h>
|
10 | 12 | #include <consensus/params.h>
|
11 | 13 | #include <netaddress.h>
|
|
19 | 21 | #include <unordered_map>
|
20 | 22 | #include <vector>
|
21 | 23 |
|
22 |
| -typedef std::map<int, uint256> MapCheckpoints; |
23 |
| - |
24 |
| -struct CCheckpointData { |
25 |
| - MapCheckpoints mapCheckpoints; |
26 |
| - |
27 |
| - int GetHeight() const { |
28 |
| - const auto& final_checkpoint = mapCheckpoints.rbegin(); |
29 |
| - return final_checkpoint->first /* height */; |
30 |
| - } |
31 |
| -}; |
32 |
| - |
33 |
| -struct AssumeutxoHash : public BaseHash<uint256> { |
34 |
| - explicit AssumeutxoHash(const uint256& hash) : BaseHash(hash) {} |
35 |
| -}; |
36 |
| - |
37 |
| -/** |
38 |
| - * Holds configuration for use during UTXO snapshot load and validation. The contents |
39 |
| - * here are security critical, since they dictate which UTXO snapshots are recognized |
40 |
| - * as valid. |
41 |
| - */ |
42 |
| -struct AssumeutxoData { |
43 |
| - //! The expected hash of the deserialized UTXO set. |
44 |
| - const AssumeutxoHash hash_serialized; |
45 |
| - |
46 |
| - //! Used to populate the nChainTx value, which is used during BlockManager::LoadBlockIndex(). |
47 |
| - //! |
48 |
| - //! We need to hardcode the value here because this is computed cumulatively using block data, |
49 |
| - //! which we do not necessarily have at the time of snapshot load. |
50 |
| - const unsigned int nChainTx; |
51 |
| -}; |
52 |
| - |
53 |
| -using MapAssumeutxo = std::map<int, const AssumeutxoData>; |
54 |
| - |
55 |
| -/** |
56 |
| - * Holds various statistics on transactions within a chain. Used to estimate |
57 |
| - * verification progress during chain sync. |
58 |
| - * |
59 |
| - * See also: CChainParams::TxData, GuessVerificationProgress. |
60 |
| - */ |
61 |
| -struct ChainTxData { |
62 |
| - int64_t nTime; //!< UNIX timestamp of last known number of transactions |
63 |
| - int64_t nTxCount; //!< total number of transactions between genesis and that timestamp |
64 |
| - double dTxRate; //!< estimated number of transactions per second after that timestamp |
65 |
| -}; |
66 |
| - |
67 |
| -/** |
68 |
| - * CChainParams defines various tweakable parameters of a given instance of the |
69 |
| - * Bitcoin system. |
70 |
| - */ |
71 |
| -class CChainParams |
72 |
| -{ |
73 |
| -public: |
74 |
| - enum Base58Type { |
75 |
| - PUBKEY_ADDRESS, |
76 |
| - SCRIPT_ADDRESS, |
77 |
| - SECRET_KEY, |
78 |
| - EXT_PUBLIC_KEY, |
79 |
| - EXT_SECRET_KEY, |
80 |
| - |
81 |
| - MAX_BASE58_TYPES |
82 |
| - }; |
83 |
| - |
84 |
| - const Consensus::Params& GetConsensus() const { return consensus; } |
85 |
| - const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; } |
86 |
| - uint16_t GetDefaultPort() const { return nDefaultPort; } |
87 |
| - uint16_t GetDefaultPort(Network net) const |
88 |
| - { |
89 |
| - return net == NET_I2P ? I2P_SAM31_PORT : GetDefaultPort(); |
90 |
| - } |
91 |
| - uint16_t GetDefaultPort(const std::string& addr) const |
92 |
| - { |
93 |
| - CNetAddr a; |
94 |
| - return a.SetSpecial(addr) ? GetDefaultPort(a.GetNetwork()) : GetDefaultPort(); |
95 |
| - } |
96 |
| - |
97 |
| - const CBlock& GenesisBlock() const { return genesis; } |
98 |
| - /** Default value for -checkmempool and -checkblockindex argument */ |
99 |
| - bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; } |
100 |
| - /** Policy: Filter transactions that do not match well-defined patterns */ |
101 |
| - bool RequireStandard() const { return fRequireStandard; } |
102 |
| - /** If this chain is exclusively used for testing */ |
103 |
| - bool IsTestChain() const { return m_is_test_chain; } |
104 |
| - /** If this chain allows time to be mocked */ |
105 |
| - bool IsMockableChain() const { return m_is_mockable_chain; } |
106 |
| - uint64_t PruneAfterHeight() const { return nPruneAfterHeight; } |
107 |
| - /** Minimum free space (in GB) needed for data directory */ |
108 |
| - uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; } |
109 |
| - /** Minimum free space (in GB) needed for data directory when pruned; Does not include prune target*/ |
110 |
| - uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; } |
111 |
| - /** Whether it is possible to mine blocks on demand (no retargeting) */ |
112 |
| - bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; } |
113 |
| - /** Return the network string */ |
114 |
| - std::string NetworkIDString() const { return strNetworkID; } |
115 |
| - /** Return the list of hostnames to look up for DNS seeds */ |
116 |
| - const std::vector<std::string>& DNSSeeds() const { return vSeeds; } |
117 |
| - const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; } |
118 |
| - const std::string& Bech32HRP() const { return bech32_hrp; } |
119 |
| - const std::vector<uint8_t>& FixedSeeds() const { return vFixedSeeds; } |
120 |
| - const CCheckpointData& Checkpoints() const { return checkpointData; } |
121 |
| - |
122 |
| - //! Get allowed assumeutxo configuration. |
123 |
| - //! @see ChainstateManager |
124 |
| - const MapAssumeutxo& Assumeutxo() const { return m_assumeutxo_data; } |
125 |
| - |
126 |
| - const ChainTxData& TxData() const { return chainTxData; } |
127 |
| - |
128 |
| - /** |
129 |
| - * SigNetOptions holds configurations for creating a signet CChainParams. |
130 |
| - */ |
131 |
| - struct SigNetOptions { |
132 |
| - std::optional<std::vector<uint8_t>> challenge{}; |
133 |
| - std::optional<std::vector<std::string>> seeds{}; |
134 |
| - }; |
135 |
| - |
136 |
| - /** |
137 |
| - * VersionBitsParameters holds activation parameters |
138 |
| - */ |
139 |
| - struct VersionBitsParameters { |
140 |
| - int64_t start_time; |
141 |
| - int64_t timeout; |
142 |
| - int min_activation_height; |
143 |
| - }; |
144 |
| - |
145 |
| - /** |
146 |
| - * RegTestOptions holds configurations for creating a regtest CChainParams. |
147 |
| - */ |
148 |
| - struct RegTestOptions { |
149 |
| - std::unordered_map<Consensus::DeploymentPos, VersionBitsParameters> version_bits_parameters{}; |
150 |
| - std::unordered_map<Consensus::BuriedDeployment, int> activation_heights{}; |
151 |
| - bool fastprune{false}; |
152 |
| - }; |
153 |
| - |
154 |
| - static std::unique_ptr<const CChainParams> RegTest(const RegTestOptions& options); |
155 |
| - static std::unique_ptr<const CChainParams> SigNet(const SigNetOptions& options); |
156 |
| - static std::unique_ptr<const CChainParams> Main(); |
157 |
| - static std::unique_ptr<const CChainParams> TestNet(); |
158 |
| - |
159 |
| -protected: |
160 |
| - CChainParams() {} |
161 |
| - |
162 |
| - Consensus::Params consensus; |
163 |
| - CMessageHeader::MessageStartChars pchMessageStart; |
164 |
| - uint16_t nDefaultPort; |
165 |
| - uint64_t nPruneAfterHeight; |
166 |
| - uint64_t m_assumed_blockchain_size; |
167 |
| - uint64_t m_assumed_chain_state_size; |
168 |
| - std::vector<std::string> vSeeds; |
169 |
| - std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES]; |
170 |
| - std::string bech32_hrp; |
171 |
| - std::string strNetworkID; |
172 |
| - CBlock genesis; |
173 |
| - std::vector<uint8_t> vFixedSeeds; |
174 |
| - bool fDefaultConsistencyChecks; |
175 |
| - bool fRequireStandard; |
176 |
| - bool m_is_test_chain; |
177 |
| - bool m_is_mockable_chain; |
178 |
| - CCheckpointData checkpointData; |
179 |
| - MapAssumeutxo m_assumeutxo_data; |
180 |
| - ChainTxData chainTxData; |
181 |
| -}; |
182 |
| - |
183 | 24 | /**
|
184 | 25 | * Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
|
185 | 26 | * @returns a CChainParams* of the chosen chain.
|
|
0 commit comments