diff options
| author | Ross Nicoll <[email protected]> | 2015-07-24 19:56:03 +0000 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2015-07-26 20:07:48 +0000 |
| commit | 35ed1cfce1cf679ed051fa2ab8d00f8878fec576 (patch) | |
| tree | e5cc7d0166abfbd2b5d4789e5f3695fde0d4535b /src/txdb.cpp | |
| parent | Merge pull request #1201 from rnicoll/1.10-sync (diff) | |
| download | discoin-35ed1cfce1cf679ed051fa2ab8d00f8878fec576.tar.xz discoin-35ed1cfce1cf679ed051fa2ab8d00f8878fec576.zip | |
Add Scrypt hash and AuxPoW header to index database
Add Scrypt hash and AuxPoW header to index database so that index can be validated
(a check that both Litecoin and Namecoin disable for simplicity). The index format
is incompatible with 1.8, as a result, however, and guidelines on performing the
upgrade will need to be prepared.
Given scope of the change, it may be advisable for services to prepare bootstrap files and destroy existing index databases entirely before reindexing. To discuss.
Diffstat (limited to 'src/txdb.cpp')
| -rw-r--r-- | src/txdb.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp index bdc67a049..7eb857ed5 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -213,6 +213,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() // Construct block index object CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash()); pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev); + pindexNew->pauxpow = diskindex.pauxpow; pindexNew->nHeight = diskindex.nHeight; pindexNew->nFile = diskindex.nFile; pindexNew->nDataPos = diskindex.nDataPos; @@ -224,11 +225,16 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nNonce = diskindex.nNonce; pindexNew->nStatus = diskindex.nStatus; pindexNew->nTx = diskindex.nTx; + pindexNew->hashBlockPoW = diskindex.hashBlockPoW; - /* Bitcoin checks the PoW here. We don't do this because - the CDiskBlockIndex does not contain the auxpow. - This check isn't important, since the data on disk should - already be valid and can be trusted. */ + if (pindexNew->nVersion.IsAuxpow()) { + if (!diskindex.pauxpow->check(diskindex.GetBlockHash(), pindexNew->nVersion.GetChainId(), Params().GetConsensus(pindexNew->nHeight))) { + return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString()); + } + } else { + if (!CheckProofOfWork(pindexNew->hashBlockPoW, pindexNew->nBits, Params().GetConsensus(pindexNew->nHeight))) + return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString()); + } pcursor->Next(); } else { |