@@ -602,47 +602,6 @@ static void BlockNotifyGenesisWait(const CBlockIndex* pBlockIndex)
602
602
}
603
603
}
604
604
605
- // If we're using -prune with -reindex, then delete block files that will be ignored by the
606
- // reindex. Since reindexing works by starting at block file 0 and looping until a blockfile
607
- // is missing, do the same here to delete any later block files after a gap. Also delete all
608
- // rev files since they'll be rewritten by the reindex anyway. This ensures that vinfoBlockFile
609
- // is in sync with what's actually on disk by the time we start downloading, so that pruning
610
- // works correctly.
611
- static void CleanupBlockRevFiles ()
612
- {
613
- std::map<std::string, fs::path> mapBlockFiles;
614
-
615
- // Glob all blk?????.dat and rev?????.dat files from the blocks directory.
616
- // Remove the rev files immediately and insert the blk file paths into an
617
- // ordered map keyed by block file index.
618
- LogPrintf (" Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n " );
619
- fs::path blocksdir = gArgs .GetBlocksDirPath ();
620
- for (fs::directory_iterator it (blocksdir); it != fs::directory_iterator (); it++) {
621
- if (fs::is_regular_file (*it) &&
622
- it->path ().filename ().string ().length () == 12 &&
623
- it->path ().filename ().string ().substr (8 ,4 ) == " .dat" )
624
- {
625
- if (it->path ().filename ().string ().substr (0 ,3 ) == " blk" )
626
- mapBlockFiles[it->path ().filename ().string ().substr (3 ,5 )] = it->path ();
627
- else if (it->path ().filename ().string ().substr (0 ,3 ) == " rev" )
628
- remove (it->path ());
629
- }
630
- }
631
-
632
- // Remove all block files that aren't part of a contiguous set starting at
633
- // zero by walking the ordered map (keys are block file indices) by
634
- // keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
635
- // start removing block files.
636
- int nContigCounter = 0 ;
637
- for (const std::pair<const std::string, fs::path>& item : mapBlockFiles) {
638
- if (atoi (item.first ) == nContigCounter) {
639
- nContigCounter++;
640
- continue ;
641
- }
642
- remove (item.second );
643
- }
644
- }
645
-
646
605
#if HAVE_SYSTEM
647
606
static void StartupNotify (const ArgsManager& args)
648
607
{
0 commit comments