Merge #915: Store block hash in CDiskBlockIndex
de36227 Store block hash in CDiskBlockIndex
This commit is contained in:
parent
57a72a0ca2
commit
ee17056ddc
@ -284,13 +284,16 @@ public:
|
|||||||
class CDiskBlockIndex : public CBlockIndex
|
class CDiskBlockIndex : public CBlockIndex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
uint256 hash;
|
||||||
uint256 hashPrev;
|
uint256 hashPrev;
|
||||||
|
|
||||||
CDiskBlockIndex() {
|
CDiskBlockIndex() {
|
||||||
|
hash = uint256();
|
||||||
hashPrev = uint256();
|
hashPrev = uint256();
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit CDiskBlockIndex(const CBlockIndex* pindex) : CBlockIndex(*pindex) {
|
explicit CDiskBlockIndex(const CBlockIndex* pindex) : CBlockIndex(*pindex) {
|
||||||
|
hash = (hash == uint256() ? pindex->GetBlockHash() : hash);
|
||||||
hashPrev = (pprev ? pprev->GetBlockHash() : uint256());
|
hashPrev = (pprev ? pprev->GetBlockHash() : uint256());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,6 +314,8 @@ public:
|
|||||||
if (nStatus & BLOCK_HAVE_UNDO)
|
if (nStatus & BLOCK_HAVE_UNDO)
|
||||||
READWRITE(VARINT(nUndoPos));
|
READWRITE(VARINT(nUndoPos));
|
||||||
|
|
||||||
|
// block hash
|
||||||
|
READWRITE(hash);
|
||||||
// block header
|
// block header
|
||||||
READWRITE(this->nVersion);
|
READWRITE(this->nVersion);
|
||||||
READWRITE(hashPrev);
|
READWRITE(hashPrev);
|
||||||
@ -322,6 +327,8 @@ public:
|
|||||||
|
|
||||||
uint256 GetBlockHash() const
|
uint256 GetBlockHash() const
|
||||||
{
|
{
|
||||||
|
if(hash != uint256()) return hash;
|
||||||
|
// should never really get here, keeping this as a fallback
|
||||||
CBlockHeader block;
|
CBlockHeader block;
|
||||||
block.nVersion = nVersion;
|
block.nVersion = nVersion;
|
||||||
block.hashPrevBlock = hashPrev;
|
block.hashPrevBlock = hashPrev;
|
||||||
|
Loading…
Reference in New Issue
Block a user