Skip to content

Commit

Permalink
Merge #146: [Wallet] Look at last CoinsView block for corruption fix …
Browse files Browse the repository at this point in the history
…process

f63c1a3 Use the greater of last meta block and last CoinsView block for corruption fix process (presstab)

Tree-SHA512: 6dee1058c50df79f9761a5838aaa6e599c38a166a31989ac710cb904e43cb3561493585890ddb2b8e08771cde80284f812235ba9dc1be9c87e7b676ca9b1bafa
  • Loading branch information
presstab committed Apr 26, 2017
2 parents e4e68bc + f63c1a3 commit bce67cb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3941,6 +3941,16 @@ bool static LoadBlockIndexDB()

//get the last block that was properly recorded to the block info file
CBlockIndex* pindexLastMeta = vSortedByHeight[vinfoBlockFile[nLastBlockFile].nHeightLast + 1].second;

//fix Assertion `hashPrevBlock == view.GetBestBlock()' failed. By adjusting height to the last recorded by coinsview
CBlockIndex* pindexCoinsView = mapBlockIndex[pcoinsTip->GetBestBlock()];
for(unsigned int i = vinfoBlockFile[nLastBlockFile].nHeightLast + 1; i < vSortedByHeight.size(); i++)
{
pindexLastMeta = vSortedByHeight[i].second;
if(pindexLastMeta->nHeight > pindexCoinsView->nHeight)
break;
}

LogPrintf("%s: Last block properly recorded: #%d %s\n", __func__, pindexLastMeta->nHeight, pindexLastMeta->GetBlockHash().ToString().c_str());

CBlock lastMetaBlock;
Expand Down

0 comments on commit bce67cb

Please sign in to comment.