Skip to content

Commit 6856beb

Browse files
committed
Have chainstate store CProof for each block header
1 parent 60f7062 commit 6856beb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/chain.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class CBlockIndex
213213
uint32_t block_height;
214214
uint32_t nBits;
215215
uint32_t nNonce;
216+
CProof proof;
216217

217218
//! (memory only) Sequential id assigned to distinguish order in which blocks are received.
218219
int32_t nSequenceId;
@@ -242,6 +243,7 @@ class CBlockIndex
242243
block_height = 0;
243244
nBits = 0;
244245
nNonce = 0;
246+
proof.SetNull();
245247
}
246248

247249
CBlockIndex()
@@ -259,6 +261,7 @@ class CBlockIndex
259261
block_height = block.block_height;
260262
nBits = block.nBits;
261263
nNonce = block.nNonce;
264+
proof = block.proof;
262265
}
263266

264267
CDiskBlockPos GetBlockPos() const {
@@ -290,6 +293,7 @@ class CBlockIndex
290293
block.block_height = block_height;
291294
block.nBits = nBits;
292295
block.nNonce = nNonce;
296+
block.proof = proof;
293297
return block;
294298
}
295299

@@ -408,8 +412,13 @@ class CDiskBlockIndex : public CBlockIndex
408412
READWRITE(hashMerkleRoot);
409413
READWRITE(nTime);
410414
READWRITE(block_height);
411-
READWRITE(nBits);
412-
READWRITE(nNonce);
415+
// For compatibility with elements 0.14 based chains
416+
if (g_signed_blocks) {
417+
READWRITE(proof);
418+
} else {
419+
READWRITE(nBits);
420+
READWRITE(nNonce);
421+
}
413422
}
414423

415424
uint256 GetBlockHash() const
@@ -422,6 +431,7 @@ class CDiskBlockIndex : public CBlockIndex
422431
block.block_height = block_height;
423432
block.nBits = nBits;
424433
block.nNonce = nNonce;
434+
block.proof = proof;
425435
return block.GetHash();
426436
}
427437

src/txdb.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
272272
pindexNew->nTime = diskindex.nTime;
273273
pindexNew->nBits = diskindex.nBits;
274274
pindexNew->nNonce = diskindex.nNonce;
275+
pindexNew->proof = diskindex.proof;
275276
pindexNew->nStatus = diskindex.nStatus;
276277
pindexNew->nTx = diskindex.nTx;
277278

0 commit comments

Comments
 (0)