aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAshley Holman <dscvlt@gmail.com>2014-05-11 07:05:04 -0500
committerAshley Holman <dscvlt@gmail.com>2014-05-12 08:09:09 -0500
commit8c93bf4c2857cdc01f0e5efca2becef08d2c5f1e (patch)
treea3c21ba90828e01a4134c93c4ff8b30b7534c26f /src
parent7a0e84dd63ac98a92fd7aafd2d432f1da71eb8da (diff)
downloadbitcoin-8c93bf4c2857cdc01f0e5efca2becef08d2c5f1e.tar.xz
LoadBlockIndexDB(): Require block db reindex if any blk*.dat files are missing.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f90f038016..4b0e3af649 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);