|
1 | 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto
|
2 | 2 | // Copyright (c) 2009-2019 The Bitcoin Core developers
|
| 3 | +// Copyright (c) 2019-2020 The Veil developers |
3 | 4 | // Distributed under the MIT software license, see the accompanying
|
4 | 5 | // file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
5 | 6 |
|
@@ -240,6 +241,14 @@ bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockF
|
240 | 241 | }
|
241 | 242 | batch.Write(DB_LAST_BLOCK, nLastFile);
|
242 | 243 | for (std::vector<const CBlockIndex*>::const_iterator it=blockinfo.begin(); it != blockinfo.end(); it++) {
|
| 244 | + CDiskBlockIndex diskindex = CDiskBlockIndex(*it); |
| 245 | + CBlockHeader bHeader = (*it)->GetBlockHeader(); |
| 246 | + uint256 hashBlock = diskindex.GetBlockHash(); |
| 247 | + if (arith_uint256(hashBlock.GetHex()) != arith_uint256((*it)->GetBlockHeader().GetHash().GetHex())) { |
| 248 | + LogPrintf("%s: *** Warning - Block %d: Hash: %s doesn't match Header Hash: %s\n", __func__, |
| 249 | + diskindex.nHeight, hashBlock.GetHex(), bHeader.GetHash().GetHex()); |
| 250 | + continue; // Don't write it |
| 251 | + } |
243 | 252 | batch.Write(std::make_pair(DB_BLOCK_INDEX, (*it)->GetBlockHash()), CDiskBlockIndex(*it));
|
244 | 253 | }
|
245 | 254 | return WriteBatch(batch, true);
|
@@ -276,6 +285,8 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
|
276 | 285 | // ignore any duplicates and mark them to be erased
|
277 | 286 | uint256 hashBlock = diskindex.GetBlockHash();
|
278 | 287 | if (hashBlock != key.second) {
|
| 288 | + LogPrintf("%s: Skipping Block %d: %s - Block Hash does not match Index Key\n", |
| 289 | + __func__, diskindex.nStatus, hashBlock.GetHex()); |
279 | 290 | pcursor->Next();
|
280 | 291 | continue;
|
281 | 292 | }
|
|
0 commit comments