@@ -140,91 +140,65 @@ class CBlockIndex
140
140
{
141
141
public:
142
142
// ! pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
143
- const uint256* phashBlock;
143
+ const uint256* phashBlock{ nullptr } ;
144
144
145
145
// ! pointer to the index of the predecessor of this block
146
- CBlockIndex* pprev;
146
+ CBlockIndex* pprev{ nullptr } ;
147
147
148
148
// ! pointer to the index of some further predecessor of this block
149
- CBlockIndex* pskip;
149
+ CBlockIndex* pskip{ nullptr } ;
150
150
151
151
// ! height of the entry in the chain. The genesis block has height 0
152
- int nHeight;
152
+ int nHeight{ 0 } ;
153
153
154
154
// ! Which # file this block is stored in (blk?????.dat)
155
- int nFile;
155
+ int nFile{ 0 } ;
156
156
157
157
// ! Byte offset within blk?????.dat where this block's data is stored
158
- unsigned int nDataPos;
158
+ unsigned int nDataPos{ 0 } ;
159
159
160
160
// ! Byte offset within rev?????.dat where this block's undo data is stored
161
- unsigned int nUndoPos;
161
+ unsigned int nUndoPos{ 0 } ;
162
162
163
163
// ! (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
164
- arith_uint256 nChainWork;
164
+ arith_uint256 nChainWork{} ;
165
165
166
166
// ! Number of transactions in this block.
167
167
// ! Note: in a potential headers-first mode, this number cannot be relied upon
168
- unsigned int nTx;
168
+ unsigned int nTx{ 0 } ;
169
169
170
170
// ! (memory only) Number of transactions in the chain up to and including this block.
171
171
// ! This value will be non-zero only if and only if transactions for this block and all its parents are available.
172
172
// ! Change to 64-bit type when necessary; won't happen before 2030
173
- unsigned int nChainTx;
173
+ unsigned int nChainTx{ 0 } ;
174
174
175
175
// ! Verification status of this block. See enum BlockStatus
176
- uint32_t nStatus;
176
+ uint32_t nStatus{ 0 } ;
177
177
178
178
// ! block header
179
- int32_t nVersion;
180
- uint256 hashMerkleRoot;
181
- uint32_t nTime;
182
- uint32_t nBits;
183
- uint32_t nNonce;
179
+ int32_t nVersion{ 0 } ;
180
+ uint256 hashMerkleRoot{} ;
181
+ uint32_t nTime{ 0 } ;
182
+ uint32_t nBits{ 0 } ;
183
+ uint32_t nNonce{ 0 } ;
184
184
185
185
// ! (memory only) Sequential id assigned to distinguish order in which blocks are received.
186
- int32_t nSequenceId;
186
+ int32_t nSequenceId{ 0 } ;
187
187
188
188
// ! (memory only) Maximum nTime in the chain up to and including this block.
189
- unsigned int nTimeMax;
190
-
191
- void SetNull ()
192
- {
193
- phashBlock = nullptr ;
194
- pprev = nullptr ;
195
- pskip = nullptr ;
196
- nHeight = 0 ;
197
- nFile = 0 ;
198
- nDataPos = 0 ;
199
- nUndoPos = 0 ;
200
- nChainWork = arith_uint256 ();
201
- nTx = 0 ;
202
- nChainTx = 0 ;
203
- nStatus = 0 ;
204
- nSequenceId = 0 ;
205
- nTimeMax = 0 ;
206
-
207
- nVersion = 0 ;
208
- hashMerkleRoot = uint256 ();
209
- nTime = 0 ;
210
- nBits = 0 ;
211
- nNonce = 0 ;
212
- }
189
+ unsigned int nTimeMax{0 };
213
190
214
191
CBlockIndex ()
215
192
{
216
- SetNull ();
217
193
}
218
194
219
195
explicit CBlockIndex (const CBlockHeader& block)
196
+ : nVersion{block.nVersion },
197
+ hashMerkleRoot{block.hashMerkleRoot },
198
+ nTime{block.nTime },
199
+ nBits{block.nBits },
200
+ nNonce{block.nNonce }
220
201
{
221
- SetNull ();
222
-
223
- nVersion = block.nVersion ;
224
- hashMerkleRoot = block.hashMerkleRoot ;
225
- nTime = block.nTime ;
226
- nBits = block.nBits ;
227
- nNonce = block.nNonce ;
228
202
}
229
203
230
204
FlatFilePos GetBlockPos () const {
0 commit comments