diff --git a/src/init.cpp b/src/init.cpp index 214bcf2d1..8dd4bddf6 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1621,15 +1621,21 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError(strErrors.str()); //// debug print - LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size()); - LogPrintf("nBestHeight = %d\n", chainActive.Height()); + { + LOCK(cs_main); + LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size()); + LogPrintf("nBestHeight = %d\n", chainActive.Height()); + } #ifdef ENABLE_WALLET - LogPrintf("setKeyPool.size() = %u\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0); - LogPrintf("mapWallet.size() = %u\n", pwalletMain ? pwalletMain->mapWallet.size() : 0); - LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0); + if (pwalletMain) + { + LOCK(pwalletMain->cs_wallet); + LogPrintf("setKeyPool.size() = %u\n", pwalletMain->setKeyPool.size()); + LogPrintf("mapWallet.size() = %u\n", pwalletMain->mapWallet.size()); + LogPrintf("mapAddressBook.size() = %u\n", pwalletMain->mapAddressBook.size()); + } #endif - if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) StartTorControl(threadGroup, scheduler); diff --git a/src/main.cpp b/src/main.cpp index 042589302..a9ad8b9a5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -67,7 +67,7 @@ CConditionVariable cvBlockChange; int nScriptCheckThreads = 0; bool fExperimentalMode = false; bool fImporting = false; -bool fReindex = false; +std::atomic_bool fReindex(false); bool fTxIndex = false; bool fInsightExplorer = false; // insightexplorer bool fAddressIndex = false; // insightexplorer @@ -4455,7 +4455,7 @@ bool static LoadBlockIndexDB() // Check whether we need to continue reindexing bool fReindexing = false; pblocktree->ReadReindexing(fReindexing); - fReindex |= fReindexing; + if(fReindexing) fReindex = true; // Check whether we have a transaction index pblocktree->ReadFlag("txindex", fTxIndex); diff --git a/src/main.h b/src/main.h index 149175a8e..e2bac7098 100644 --- a/src/main.h +++ b/src/main.h @@ -139,7 +139,7 @@ extern CWaitableCriticalSection csBestBlock; extern CConditionVariable cvBlockChange; extern bool fExperimentalMode; extern bool fImporting; -extern bool fReindex; +extern std::atomic_bool fReindex; extern int nScriptCheckThreads; extern bool fTxIndex; diff --git a/src/txdb.h b/src/txdb.h index efbc29bc1..b27bc4abb 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -107,12 +107,12 @@ private: public: bool WriteBatchSync(const std::vector >& fileInfo, int nLastFile, const std::vector& blockinfo); bool EraseBatchSync(const std::vector& blockinfo); - bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo); + bool ReadBlockFileInfo(int nFile, CBlockFileInfo &info); bool ReadLastBlockFile(int &nFile); - bool WriteReindexing(bool fReindex); - bool ReadReindexing(bool &fReindex); + bool WriteReindexing(bool fReindexing); + bool ReadReindexing(bool &fReindexing); bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos); - bool WriteTxIndex(const std::vector > &list); + bool WriteTxIndex(const std::vector > &vect); // START insightexplorer bool UpdateAddressUnspentIndex(const std::vector &vect);