@@ -831,47 +831,6 @@ static void BlockNotifyGenesisWait(const CBlockIndex* pBlockIndex)
831
831
}
832
832
}
833
833
834
- // If we're using -prune with -reindex, then delete block files that will be ignored by the
835
- // reindex. Since reindexing works by starting at block file 0 and looping until a blockfile
836
- // is missing, do the same here to delete any later block files after a gap. Also delete all
837
- // rev files since they'll be rewritten by the reindex anyway. This ensures that vinfoBlockFile
838
- // is in sync with what's actually on disk by the time we start downloading, so that pruning
839
- // works correctly.
840
- static void CleanupBlockRevFiles ()
841
- {
842
- std::map<std::string, fs::path> mapBlockFiles;
843
-
844
- // Glob all blk?????.dat and rev?????.dat files from the blocks directory.
845
- // Remove the rev files immediately and insert the blk file paths into an
846
- // ordered map keyed by block file index.
847
- LogPrintf (" Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n " );
848
- fs::path blocksdir = gArgs .GetBlocksDirPath ();
849
- for (fs::directory_iterator it (blocksdir); it != fs::directory_iterator (); it++) {
850
- if (fs::is_regular_file (*it) &&
851
- it->path ().filename ().string ().length () == 12 &&
852
- it->path ().filename ().string ().substr (8 ,4 ) == " .dat" )
853
- {
854
- if (it->path ().filename ().string ().substr (0 ,3 ) == " blk" )
855
- mapBlockFiles[it->path ().filename ().string ().substr (3 ,5 )] = it->path ();
856
- else if (it->path ().filename ().string ().substr (0 ,3 ) == " rev" )
857
- remove (it->path ());
858
- }
859
- }
860
-
861
- // Remove all block files that aren't part of a contiguous set starting at
862
- // zero by walking the ordered map (keys are block file indices) by
863
- // keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
864
- // start removing block files.
865
- int nContigCounter = 0 ;
866
- for (const std::pair<const std::string, fs::path>& item : mapBlockFiles) {
867
- if (LocaleIndependentAtoi<int >(item.first ) == nContigCounter) {
868
- nContigCounter++;
869
- continue ;
870
- }
871
- remove (item.second );
872
- }
873
- }
874
-
875
834
#if HAVE_SYSTEM
876
835
static void StartupNotify (const ArgsManager& args)
877
836
{
0 commit comments