mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 05:23:01 +01:00
LoadBlockIndexDB(): Require block db reindex if any blk*.dat files are missing.
This commit is contained in:
parent
7a0e84dd63
commit
8c93bf4c28
18
src/main.cpp
18
src/main.cpp
@ -2941,6 +2941,24 @@ bool static LoadBlockIndexDB()
|
|||||||
if (pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile))
|
if (pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile))
|
||||||
LogPrintf("LoadBlockIndexDB(): last block file info: %s\n", infoLastBlockFile.ToString());
|
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
|
// Check whether we need to continue reindexing
|
||||||
bool fReindexing = false;
|
bool fReindexing = false;
|
||||||
pblocktree->ReadReindexing(fReindexing);
|
pblocktree->ReadReindexing(fReindexing);
|
||||||
|
Loading…
Reference in New Issue
Block a user