Support absence of wallet (pwalletMain==NULL) in several locations,

notably RPC.
This commit is contained in:
Jeff Garzik
2013-08-25 00:00:02 -04:00
parent 19c415b1cf
commit b0730874d9
6 changed files with 123 additions and 92 deletions

View File

@@ -108,7 +108,8 @@ void Shutdown()
nTransactionsUpdated++;
StopRPCThreads();
ShutdownRPCMining();
bitdb.Flush(false);
if (pwalletMain)
bitdb.Flush(false);
GenerateBitcoins(false, NULL);
StopNode();
{
@@ -123,10 +124,12 @@ void Shutdown()
delete pcoinsdbview; pcoinsdbview = NULL;
delete pblocktree; pblocktree = NULL;
}
bitdb.Flush(true);
if (pwalletMain)
bitdb.Flush(true);
boost::filesystem::remove(GetPidFile());
UnregisterAllWallets();
delete pwalletMain;
if (pwalletMain)
delete pwalletMain;
}
//
@@ -981,9 +984,9 @@ bool AppInit2(boost::thread_group& threadGroup)
//// debug print
LogPrintf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size());
LogPrintf("nBestHeight = %d\n", nBestHeight);
LogPrintf("setKeyPool.size() = %"PRIszu"\n", pwalletMain->setKeyPool.size());
LogPrintf("mapWallet.size() = %"PRIszu"\n", pwalletMain->mapWallet.size());
LogPrintf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain->mapAddressBook.size());
LogPrintf("setKeyPool.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
LogPrintf("mapWallet.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
LogPrintf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
StartNode(threadGroup);
@@ -993,17 +996,20 @@ bool AppInit2(boost::thread_group& threadGroup)
StartRPCThreads();
// Generate coins in the background
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain);
if (pwalletMain)
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain);
// ********************************************************* Step 12: finished
uiInterface.InitMessage(_("Done loading"));
// Add wallet transactions that aren't already in a block to mapTransactions
pwalletMain->ReacceptWalletTransactions();
if (pwalletMain) {
// Add wallet transactions that aren't already in a block to mapTransactions
pwalletMain->ReacceptWalletTransactions();
// Run a thread to flush wallet periodically
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile)));
// Run a thread to flush wallet periodically
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile)));
}
return !fRequestShutdown;
}