aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-05-19 16:01:43 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-05-19 17:02:29 +0200
commitaed38cbcb54772a9b05aff0759288f4fefaec70b (patch)
tree6fa09ca8ddb08aa96c0a4df202801538efe3c0dd
parentc26acfc308482bac901ab3c7368c951514f13429 (diff)
parent8c93bf4c2857cdc01f0e5efca2becef08d2c5f1e (diff)
Merge pull request #4173
8c93bf4 LoadBlockIndexDB(): Require block db reindex if any blk*.dat files are missing. (Ashley Holman) 7a0e84d ProcessGetData(): abort if a block file is missing from disk (Ashley Holman)
-rw-r--r--src/main.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f7c53052e1..3bed4fdc44 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)