aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-05-01 19:09:04 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2013-05-01 19:21:55 +0200
commit2aceeb01a9b0b0c6bfa0d56211453e87bc33d6e4 (patch)
tree1677a32a75dcfd038a917175d3cc80b6ffac9f39 /src
parenteef2091fe9ee39ecd8e874c91d3ab0ff023c5356 (diff)
Bugfix: if no bestblock record is present, do a -rescan
It is possible to have a wallet.dat file without any bestblock record at all (if created offline, for example), which - when loaded into a client with a up-to-date chain - does no rescan and shows no transactions. Also make sure to write the current best block after a rescan, so it isn't necessary twice.
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 3845cfad81..3c1040a791 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -988,6 +988,8 @@ bool AppInit2(boost::thread_group& threadGroup)
CBlockLocator locator;
if (walletdb.ReadBestBlock(locator))
pindexRescan = locator.GetBlockIndex();
+ else
+ pindexRescan = pindexGenesisBlock;
}
if (pindexBest && pindexBest != pindexRescan)
{
@@ -996,6 +998,8 @@ bool AppInit2(boost::thread_group& threadGroup)
nStart = GetTimeMillis();
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
+ pwalletMain->SetBestChain(CBlockLocator(pindexBest));
+ nWalletDBUpdated++;
}
// ********************************************************* Step 9: import blocks