|
|
@ -1694,7 +1694,7 @@ bool SetBestChain(CBlockIndex* pindexNew) |
|
|
|
// Find the fork (typically, there is none)
|
|
|
|
// Find the fork (typically, there is none)
|
|
|
|
CBlockIndex* pfork = view.GetBestBlock(); |
|
|
|
CBlockIndex* pfork = view.GetBestBlock(); |
|
|
|
CBlockIndex* plonger = pindexNew; |
|
|
|
CBlockIndex* plonger = pindexNew; |
|
|
|
while (pfork != plonger) |
|
|
|
while (pfork && pfork != plonger) |
|
|
|
{ |
|
|
|
{ |
|
|
|
while (plonger->nHeight > pfork->nHeight) |
|
|
|
while (plonger->nHeight > pfork->nHeight) |
|
|
|
if (!(plonger = plonger->pprev)) |
|
|
|
if (!(plonger = plonger->pprev)) |
|
|
@ -2330,13 +2330,18 @@ bool static LoadBlockIndexDB() |
|
|
|
if (pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile)) |
|
|
|
if (pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile)) |
|
|
|
printf("LoadBlockIndex(): last block file: %s\n", infoLastBlockFile.ToString().c_str()); |
|
|
|
printf("LoadBlockIndex(): last block file: %s\n", infoLastBlockFile.ToString().c_str()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Load bnBestInvalidWork, OK if it doesn't exist
|
|
|
|
|
|
|
|
pblocktree->ReadBestInvalidWork(bnBestInvalidWork); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check whether we need to continue reindexing
|
|
|
|
|
|
|
|
bool fReindexing = false; |
|
|
|
|
|
|
|
pblocktree->ReadReindexing(fReindexing); |
|
|
|
|
|
|
|
fReindex |= fReindexing; |
|
|
|
|
|
|
|
|
|
|
|
// Load hashBestChain pointer to end of best chain
|
|
|
|
// Load hashBestChain pointer to end of best chain
|
|
|
|
pindexBest = pcoinsTip->GetBestBlock(); |
|
|
|
pindexBest = pcoinsTip->GetBestBlock(); |
|
|
|
if (pindexBest == NULL) |
|
|
|
if (pindexBest == NULL) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
if (pindexGenesisBlock == NULL) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
hashBestChain = pindexBest->GetBlockHash(); |
|
|
|
hashBestChain = pindexBest->GetBlockHash(); |
|
|
|
nBestHeight = pindexBest->nHeight; |
|
|
|
nBestHeight = pindexBest->nHeight; |
|
|
|
bnBestChainWork = pindexBest->bnChainWork; |
|
|
|
bnBestChainWork = pindexBest->bnChainWork; |
|
|
@ -2352,14 +2357,6 @@ bool static LoadBlockIndexDB() |
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight, |
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight, |
|
|
|
DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
|
|
|
|
|
|
|
|
// Load bnBestInvalidWork, OK if it doesn't exist
|
|
|
|
|
|
|
|
pblocktree->ReadBestInvalidWork(bnBestInvalidWork); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check whether we need to continue reindexing
|
|
|
|
|
|
|
|
bool fReindexing = false; |
|
|
|
|
|
|
|
pblocktree->ReadReindexing(fReindexing); |
|
|
|
|
|
|
|
fReindex |= fReindexing; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Verify blocks in the best chain
|
|
|
|
// Verify blocks in the best chain
|
|
|
|
int nCheckLevel = GetArg("-checklevel", 1); |
|
|
|
int nCheckLevel = GetArg("-checklevel", 1); |
|
|
|
int nCheckDepth = GetArg( "-checkblocks", 2500); |
|
|
|
int nCheckDepth = GetArg( "-checkblocks", 2500); |
|
|
|