diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoin-cli.cpp | 2 | ||||
-rw-r--r-- | src/bitcoind.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 20 | ||||
-rw-r--r-- | src/qt/bitcoin.cpp | 2 | ||||
-rw-r--r-- | src/util.cpp | 16 | ||||
-rw-r--r-- | src/util.h | 1 |
6 files changed, 42 insertions, 1 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index ca6950a162..ce9e7a4027 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -58,6 +58,8 @@ static bool AppInitRPC(int argc, char* argv[]) int main(int argc, char* argv[]) { + SetupEnvironment(); + try { if(!AppInitRPC(argc, argv)) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 17aa0c9d4b..78c8b2ba0e 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -172,6 +172,8 @@ bool AppInit(int argc, char* argv[]) int main(int argc, char* argv[]) { + SetupEnvironment(); + bool fRet = false; // Connect bitcoind signal handlers diff --git a/src/main.cpp b/src/main.cpp index 7bb3bdb70c..c54fa65233 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2941,6 +2941,24 @@ bool static LoadBlockIndexDB() if (pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile)) LogPrintf("LoadBlockIndexDB(): last block file info: %s\n", infoLastBlockFile.ToString()); + // Check presence of blk files + LogPrintf("Checking all blk files are present...\n"); + set<int> setBlkDataFiles; + BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) + { + CBlockIndex* pindex = item.second; + if (pindex->nStatus & BLOCK_HAVE_DATA) { + setBlkDataFiles.insert(pindex->nFile); + } + } + for (std::set<int>::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++) + { + CDiskBlockPos pos(*it, 0); + if (!CAutoFile(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION)) { + return false; + } + } + // Check whether we need to continue reindexing bool fReindexing = false; pblocktree->ReadReindexing(fReindexing); @@ -3373,7 +3391,7 @@ void static ProcessGetData(CNode* pfrom) { // Send block from disk CBlock block; - ReadBlockFromDisk(block, (*mi).second); + assert(ReadBlockFromDisk(block, (*mi).second)); if (inv.type == MSG_BLOCK) pfrom->PushMessage("block", block); else // MSG_FILTERED_BLOCK) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 31716ab825..45d7a52889 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -459,6 +459,8 @@ WId BitcoinApplication::getMainWinId() const #ifndef BITCOIN_QT_TEST int main(int argc, char *argv[]) { + SetupEnvironment(); + /// 1. Parse command-line options. These take precedence over anything else. // Command-line options take precedence: ParseParameters(argc, argv); diff --git a/src/util.cpp b/src/util.cpp index 205af738d5..aa3adf89ec 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1384,3 +1384,19 @@ bool ParseInt32(const std::string& str, int32_t *out) n <= std::numeric_limits<int32_t>::max(); } +void SetupEnvironment() +{ + #ifndef WIN32 + try + { + #if BOOST_FILESYSTEM_VERSION == 3 + boost::filesystem::path::codecvt(); // Raises runtime error if current locale is invalid + #else // boost filesystem v2 + std::locale(); // Raises runtime error if current locale is invalid + #endif + } catch(std::runtime_error &e) + { + setenv("LC_ALL", "C", 1); // Force C locale + } + #endif +} diff --git a/src/util.h b/src/util.h index 52ca6e579b..97185073e0 100644 --- a/src/util.h +++ b/src/util.h @@ -106,6 +106,7 @@ extern volatile bool fReopenDebugLog; void RandAddSeed(); void RandAddSeedPerfmon(); +void SetupEnvironment(); /* Return true if log accepts specified category */ bool LogAcceptCategory(const char* category); |