mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Allow lengthy block reconnections to be interrupted
When the coin database is out of date with the block database, the best block in it is automatically switched to. This reconnection process can take time, so allow it to be interrupted. This also stops block connection as soon as shutdown is requested, leading to a faster shutdown.
This commit is contained in:
parent
c8b2e4426b
commit
3fb9b99cca
@ -345,7 +345,7 @@ void ThreadImport(void *data) {
|
||||
if (fReindex) {
|
||||
CImportingNow imp;
|
||||
int nFile = 0;
|
||||
while (!fShutdown) {
|
||||
while (!fRequestShutdown) {
|
||||
CDiskBlockPos pos(nFile, 0);
|
||||
FILE *file = OpenBlockFile(pos, true);
|
||||
if (!file)
|
||||
@ -354,7 +354,7 @@ void ThreadImport(void *data) {
|
||||
LoadExternalBlockFile(file, &pos);
|
||||
nFile++;
|
||||
}
|
||||
if (!fShutdown) {
|
||||
if (!fRequestShutdown) {
|
||||
pblocktree->WriteReindexing(false);
|
||||
fReindex = false;
|
||||
printf("Reindexing finished\n");
|
||||
@ -363,7 +363,7 @@ void ThreadImport(void *data) {
|
||||
|
||||
// hardcoded $DATADIR/bootstrap.dat
|
||||
filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
|
||||
if (filesystem::exists(pathBootstrap) && !fShutdown) {
|
||||
if (filesystem::exists(pathBootstrap) && !fRequestShutdown) {
|
||||
FILE *file = fopen(pathBootstrap.string().c_str(), "rb");
|
||||
if (file) {
|
||||
CImportingNow imp;
|
||||
@ -376,7 +376,7 @@ void ThreadImport(void *data) {
|
||||
|
||||
// -loadblock=
|
||||
BOOST_FOREACH(boost::filesystem::path &path, import->vFiles) {
|
||||
if (fShutdown)
|
||||
if (fRequestShutdown)
|
||||
break;
|
||||
FILE *file = fopen(path.string().c_str(), "rb");
|
||||
if (file) {
|
||||
|
@ -1240,9 +1240,12 @@ bool ConnectBestBlock() {
|
||||
|
||||
if (pindexTest->pprev == NULL || pindexTest->pnext != NULL) {
|
||||
reverse(vAttach.begin(), vAttach.end());
|
||||
BOOST_FOREACH(CBlockIndex *pindexSwitch, vAttach)
|
||||
BOOST_FOREACH(CBlockIndex *pindexSwitch, vAttach) {
|
||||
if (fRequestShutdown)
|
||||
break;
|
||||
if (!SetBestChain(pindexSwitch))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
pindexTest = pindexTest->pprev;
|
||||
@ -2553,7 +2556,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
||||
}
|
||||
}
|
||||
uint64 nRewind = blkdat.GetPos();
|
||||
while (blkdat.good() && !blkdat.eof() && !fShutdown) {
|
||||
while (blkdat.good() && !blkdat.eof() && !fRequestShutdown) {
|
||||
blkdat.SetPos(nRewind);
|
||||
nRewind++; // start one byte further next time, in case of failure
|
||||
blkdat.SetLimit(); // remove former limit
|
||||
|
@ -64,7 +64,7 @@ bool fDebug = false;
|
||||
bool fDebugNet = false;
|
||||
bool fPrintToConsole = false;
|
||||
bool fPrintToDebugger = false;
|
||||
bool fRequestShutdown = false;
|
||||
volatile bool fRequestShutdown = false;
|
||||
bool fShutdown = false;
|
||||
bool fDaemon = false;
|
||||
bool fServer = false;
|
||||
|
@ -132,7 +132,7 @@ extern bool fDebug;
|
||||
extern bool fDebugNet;
|
||||
extern bool fPrintToConsole;
|
||||
extern bool fPrintToDebugger;
|
||||
extern bool fRequestShutdown;
|
||||
extern volatile bool fRequestShutdown;
|
||||
extern bool fShutdown;
|
||||
extern bool fDaemon;
|
||||
extern bool fServer;
|
||||
|
Loading…
Reference in New Issue
Block a user