Have chainstate store CProof for each block header

This commit is contained in:
Gregory Sanders 2018-12-07 10:28:35 +01:00
parent 60f70620c2
commit 6856bebb93
2 changed files with 13 additions and 2 deletions

View file

@ -213,6 +213,7 @@ public:
uint32_t block_height;
uint32_t nBits;
uint32_t nNonce;
CProof proof;
//! (memory only) Sequential id assigned to distinguish order in which blocks are received.
int32_t nSequenceId;
@ -242,6 +243,7 @@ public:
block_height = 0;
nBits = 0;
nNonce = 0;
proof.SetNull();
}
CBlockIndex()
@ -259,6 +261,7 @@ public:
block_height = block.block_height;
nBits = block.nBits;
nNonce = block.nNonce;
proof = block.proof;
}
CDiskBlockPos GetBlockPos() const {
@ -290,6 +293,7 @@ public:
block.block_height = block_height;
block.nBits = nBits;
block.nNonce = nNonce;
block.proof = proof;
return block;
}
@ -408,8 +412,13 @@ public:
READWRITE(hashMerkleRoot);
READWRITE(nTime);
READWRITE(block_height);
READWRITE(nBits);
READWRITE(nNonce);
// For compatibility with elements 0.14 based chains
if (g_signed_blocks) {
READWRITE(proof);
} else {
READWRITE(nBits);
READWRITE(nNonce);
}
}
uint256 GetBlockHash() const
@ -422,6 +431,7 @@ public:
block.block_height = block_height;
block.nBits = nBits;
block.nNonce = nNonce;
block.proof = proof;
return block.GetHash();
}

View file

@ -272,6 +272,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
pindexNew->nTime = diskindex.nTime;
pindexNew->nBits = diskindex.nBits;
pindexNew->nNonce = diskindex.nNonce;
pindexNew->proof = diskindex.proof;
pindexNew->nStatus = diskindex.nStatus;
pindexNew->nTx = diskindex.nTx;