diff options
author | Jeff Garzik <jgarzik@bitpay.com> | 2013-08-25 00:00:02 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@bitpay.com> | 2013-10-01 16:14:37 -0400 |
commit | b0730874d95e42953736f49d8041221d698ed95a (patch) | |
tree | db3e8841f61b5efccfbc1b4bc2a0b99380a64ce0 /src/init.cpp | |
parent | 19c415b1cf0dc4fd5fe08e8e7e146c7996261170 (diff) |
Support absence of wallet (pwalletMain==NULL) in several locations,
notably RPC.
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/init.cpp b/src/init.cpp index d8d1a55fc9..1f6826413a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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; } |