Merge pull request #2603 from sipa/nobestblock

Bugfix: if no bestblock record is present, do a -rescan
This commit is contained in:
Pieter Wuille 2013-05-03 14:08:46 -07:00
commit aa6b3061ee
1 changed files with 4 additions and 0 deletions

View File

@ -987,6 +987,8 @@ bool AppInit2(boost::thread_group& threadGroup)
CBlockLocator locator; CBlockLocator locator;
if (walletdb.ReadBestBlock(locator)) if (walletdb.ReadBestBlock(locator))
pindexRescan = locator.GetBlockIndex(); pindexRescan = locator.GetBlockIndex();
else
pindexRescan = pindexGenesisBlock;
} }
if (pindexBest && pindexBest != pindexRescan) if (pindexBest && pindexBest != pindexRescan)
{ {
@ -995,6 +997,8 @@ bool AppInit2(boost::thread_group& threadGroup)
nStart = GetTimeMillis(); nStart = GetTimeMillis();
pwalletMain->ScanForWalletTransactions(pindexRescan, true); pwalletMain->ScanForWalletTransactions(pindexRescan, true);
printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart); printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
pwalletMain->SetBestChain(CBlockLocator(pindexBest));
nWalletDBUpdated++;
} }
// ********************************************************* Step 9: import blocks // ********************************************************* Step 9: import blocks