mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Merge #15118: Refactor block file logic
04cca33094Style cleanup. (Jim Posen)4c01e4e159flatfile: Unit tests for FlatFileSeq methods. (Jim Posen)65a489e93dscripted-diff: Rename CBlockDiskPos to FlatFilePos. (Jim Posen)d6d8a78f26Move CDiskBlockPos from chain to flatfile. (Jim Posen)e0380933e3validation: Refactor file flush logic into FlatFileSeq. (Jim Posen)992404b31evalidation: Refactor block file pre-allocation into FlatFileSeq. (Jim Posen)e2d2abb99fvalidation: Refactor OpenDiskFile into method on FlatFileSeq. (Jim Posen)9183d6ef65validation: Extract basic block file logic into FlatFileSeq class. (Jim Posen)62e7addb63util: Move CheckDiskSpace to util. (Jim Posen) Pull request description: This cleans up and refactors block file helpers so that they may be used by the block filter indexer. Per [design discussion](https://github.com/bitcoin/bitcoin/pull/14121#issuecomment-451252591) about storing BIP 157 block filters, it has been suggested that they are stored in the same way as block and undo data. This refactor is sufficient to simplify file operations for this use case, though in the future perhaps more pruning-related logic ought to be moved into the new classes. The basic abstraction is a `FlatFileSeq` which manages access to a sequence of numbered files into which raw data is written. Tree-SHA512: b2108756777f2dad8964a1a2ef2764486e708a4a4a8cfac47b5de8bcb0625388964438eb096b10cfd9ea39212c299b5cb32fa943e768db2333cf49ea7def157e
This commit is contained in:
@@ -668,8 +668,8 @@ static void ThreadImport(std::vector<fs::path> vImportFiles)
|
||||
if (fReindex) {
|
||||
int nFile = 0;
|
||||
while (true) {
|
||||
CDiskBlockPos pos(nFile, 0);
|
||||
if (!fs::exists(GetBlockPosFilename(pos, "blk")))
|
||||
FlatFilePos pos(nFile, 0);
|
||||
if (!fs::exists(GetBlockPosFilename(pos)))
|
||||
break; // No block files left to reindex
|
||||
FILE *file = OpenBlockFile(pos, true);
|
||||
if (!file)
|
||||
@@ -1669,11 +1669,11 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||
|
||||
// ********************************************************* Step 11: import blocks
|
||||
|
||||
if (!CheckDiskSpace(/* additional_bytes */ 0, /* blocks_dir */ false)) {
|
||||
if (!CheckDiskSpace(GetDataDir())) {
|
||||
InitError(strprintf(_("Error: Disk space is low for %s"), GetDataDir()));
|
||||
return false;
|
||||
}
|
||||
if (!CheckDiskSpace(/* additional_bytes */ 0, /* blocks_dir */ true)) {
|
||||
if (!CheckDiskSpace(GetBlocksDir())) {
|
||||
InitError(strprintf(_("Error: Disk space is low for %s"), GetBlocksDir()));
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user