Skip to content

Commit faec3dc

Browse files
author
MarcoFalke
committed
init: Remove boost from ThreadImport
1 parent ae32e5c commit faec3dc

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/init.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,10 @@ static void ThreadImport(std::vector<fs::path> vImportFiles)
708708
break; // This error is logged in OpenBlockFile
709709
LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile);
710710
LoadExternalBlockFile(chainparams, file, &pos);
711+
if (ShutdownRequested()) {
712+
LogPrintf("Shutdown requested. Exit %s\n", __func__);
713+
return;
714+
}
711715
nFile++;
712716
}
713717
pblocktree->WriteReindexing(false);
@@ -723,6 +727,10 @@ static void ThreadImport(std::vector<fs::path> vImportFiles)
723727
if (file) {
724728
LogPrintf("Importing blocks file %s...\n", path.string());
725729
LoadExternalBlockFile(chainparams, file);
730+
if (ShutdownRequested()) {
731+
LogPrintf("Shutdown requested. Exit %s\n", __func__);
732+
return;
733+
}
726734
} else {
727735
LogPrintf("Warning: Could not open blocks file %s\n", path.string());
728736
}

src/validation.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4637,7 +4637,7 @@ bool LoadGenesisBlock(const CChainParams& chainparams)
46374637
return ::ChainstateActive().LoadGenesisBlock(chainparams);
46384638
}
46394639

4640-
bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFilePos *dbp)
4640+
void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFilePos* dbp)
46414641
{
46424642
// Map of disk positions for blocks with unknown parent (only used for reindex)
46434643
static std::multimap<uint256, FlatFilePos> mapBlocksUnknownParent;
@@ -4649,7 +4649,7 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
46494649
CBufferedFile blkdat(fileIn, 2*MAX_BLOCK_SERIALIZED_SIZE, MAX_BLOCK_SERIALIZED_SIZE+8, SER_DISK, CLIENT_VERSION);
46504650
uint64_t nRewind = blkdat.GetPos();
46514651
while (!blkdat.eof()) {
4652-
boost::this_thread::interruption_point();
4652+
if (ShutdownRequested()) return;
46534653

46544654
blkdat.SetPos(nRewind);
46554655
nRewind++; // start one byte further next time, in case of failure
@@ -4754,9 +4754,7 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
47544754
} catch (const std::runtime_error& e) {
47554755
AbortNode(std::string("System error: ") + e.what());
47564756
}
4757-
if (nLoaded > 0)
4758-
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart);
4759-
return nLoaded > 0;
4757+
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart);
47604758
}
47614759

47624760
void CChainState::CheckBlockIndex(const Consensus::Params& consensusParams)

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ FILE* OpenBlockFile(const FlatFilePos &pos, bool fReadOnly = false);
180180
/** Translation to a filesystem path */
181181
fs::path GetBlockPosFilename(const FlatFilePos &pos);
182182
/** Import blocks from an external file */
183-
bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFilePos *dbp = nullptr);
183+
void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFilePos* dbp = nullptr);
184184
/** Ensures we have a genesis block in the block tree, possibly writing one to disk. */
185185
bool LoadGenesisBlock(const CChainParams& chainparams);
186186
/** Load the block tree and coins database from disk,

0 commit comments

Comments
 (0)