From 1a6080508c57a6d942f8a7d05ff2544058a209ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 13 Apr 2018 19:29:09 +0300 Subject: [PATCH] Test --- src/init.cpp | 5 ++++- src/main.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 3bacc7087..f47b1ee13 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -69,6 +69,7 @@ using namespace std; extern void ThreadSendAlert(); +extern int32_t KOMODO_LOADINGBLOCKS; ZCJoinSplit* pzcashParams = NULL; @@ -625,6 +626,7 @@ void ThreadImport(std::vector vImportFiles) LogPrintf("Reindexing finished\n"); // To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked): InitBlockIndex(); + KOMODO_LOADINGBLOCKS = 0; } // hardcoded $DATADIR/bootstrap.dat @@ -1421,7 +1423,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) strLoadError = _("Error initializing block database"); break; } - + KOMODO_LOADINGBLOCKS = 0; // Check for changed -txindex state if (fTxIndex != GetBoolArg("-txindex", true)) { strLoadError = _("You need to rebuild the database using -reindex to change -txindex"); @@ -1483,6 +1485,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } } + KOMODO_LOADINGBLOCKS = 0; // As LoadBlockIndex can take several minutes, it's possible the user // requested to kill the GUI during the last operation. If so, exit. diff --git a/src/main.cpp b/src/main.cpp index 50b84b91b..bde26c086 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4037,9 +4037,10 @@ bool CheckDiskSpace(uint64_t nAdditionalBytes) return true; } + FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly) { - static int32_t didinit; long fsize,fpos; int32_t incr = 16*1024*1024; + static int32_t didinit[1000]; long fsize,fpos; int32_t incr = 16*1024*1024; if (pos.IsNull()) return NULL; boost::filesystem::path path = GetBlockPosFilename(pos, prefix); @@ -4051,7 +4052,7 @@ FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly) LogPrintf("Unable to open file %s\n", path.string()); return NULL; } - if ( didinit == 0 && strcmp(prefix,(char *)"blk") == 0 ) + if ( pos.nFile < sizeof(didinit)/sizeof(*didinit) && didinit[pos.nFile] == 0 && strcmp(prefix,(char *)"blk") == 0 ) { fpos = ftell(file); fseek(file,0,SEEK_END); @@ -4065,12 +4066,11 @@ FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly) while ( fread(ignore,1,incr,file) == incr ) fprintf(stderr,"."); free(ignore); - fprintf(stderr,"loaded %ld bytes set fpos.%ld loading.%d\n",(long)ftell(file),(long)fpos,KOMODO_LOADINGBLOCKS); + fprintf(stderr,"blk.%d loaded %ld bytes set fpos.%ld loading.%d\n",(int)pos.nFile,(long)ftell(file),(long)fpos,KOMODO_LOADINGBLOCKS); } } fseek(file,fpos,SEEK_SET); - KOMODO_LOADINGBLOCKS = 0; - didinit = 1; + didinit[pos.nFile] = 1; } if (pos.nPos) { if (fseek(file, pos.nPos, SEEK_SET)) {