Skip to content

Commit 42fd503

Browse files
committed
Merge #18786: init: Remove boost from ThreadImport
faec3dc init: Remove boost from ThreadImport (MarcoFalke) Pull request description: Can be tested by calling `-reindex` or `-loadblock` and then pressing `CTRL`+`C`. Should print something like: ``` ... 2020-04-27T19:34:31Z [loadblk] Reindexing block file blk00005.dat... ^C2020-04-27T19:34:32Z [loadblk] Shutdown requested. Exit ThreadImport 2020-04-27T19:34:32Z [qt-init] Interrupting HTTP server ... ``` ACKs for top commit: laanwj: Code review ACK faec3dc hebasto: ACK faec3dc, tested on Linux Mint 19.3 (x86_64) both `bitcoind` and `bitcoin-qt` binaries. Tree-SHA512: e105af18d98296d82ec99f48e478cf44577e3c32f7e4b47617a7bc7cbf71d6becb92722f229a1be38d58ad29712704509ad9740d8ab8cd3104cf90057664b437
2 parents 0a729b0 + faec3dc commit 42fd503

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
@@ -4644,7 +4644,7 @@ bool LoadGenesisBlock(const CChainParams& chainparams)
46444644
return ::ChainstateActive().LoadGenesisBlock(chainparams);
46454645
}
46464646

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

46614661
blkdat.SetPos(nRewind);
46624662
nRewind++; // start one byte further next time, in case of failure
@@ -4761,9 +4761,7 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
47614761
} catch (const std::runtime_error& e) {
47624762
AbortNode(std::string("System error: ") + e.what());
47634763
}
4764-
if (nLoaded > 0)
4765-
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart);
4766-
return nLoaded > 0;
4764+
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart);
47674765
}
47684766

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

src/validation.h

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

0 commit comments

Comments
 (0)