Skip to content

Commit 3275c6e

Browse files
committed
Merge bitcoin/bitcoin#21727: refactor: Move more stuff to blockstorage
fa09a9e style: Add { } to multi-line if (MarcoFalke) fadafab move-only: Move functions to blockstorage (MarcoFalke) fa7e64d move-only: Move constants to blockstorage (MarcoFalke) fa247a3 refactor: Move block storage globals to blockstorage (MarcoFalke) fa81c30 refactor: Move pruning/reindex/importing globals to blockstorage (MarcoFalke) Pull request description: See #21575 ACKs for top commit: Sjors: ACK fa09a9e kiminuo: ACK fa09a9e laanwj: Code review ACK fa09a9e promag: Code review ACK fa09a9e. Since last review Tree-SHA512: 2eb6962ff44da6b77f3058fc02ec66ab742e25ae8dcc8ec62b062896571910d43ca7c4bb16fb3ccb5e5245195b8dec6384b6c8d442fa97ca28d93bdff347d677
2 parents 23109cc + fa09a9e commit 3275c6e

File tree

8 files changed

+383
-349
lines changed

8 files changed

+383
-349
lines changed

src/index/txindex.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <index/disktxpos.h>
66
#include <index/txindex.h>
7+
#include <node/blockstorage.h>
78
#include <node/ui_interface.h>
89
#include <shutdown.h>
910
#include <util/system.h>

src/init.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -602,47 +602,6 @@ static void BlockNotifyGenesisWait(const CBlockIndex* pBlockIndex)
602602
}
603603
}
604604

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-
646605
#if HAVE_SYSTEM
647606
static void StartupNotify(const ArgsManager& args)
648607
{

0 commit comments

Comments
 (0)