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