mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
blockstorage: do not flush block to disk if it is already there
test: ensure we can reindex from read-only block files now
This commit is contained in:
@@ -906,19 +906,19 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
|
||||
if (!fKnown) {
|
||||
LogPrint(BCLog::BLOCKSTORAGE, "Leaving block file %i: %s (onto %i) (height %i)\n",
|
||||
last_blockfile, m_blockfile_info[last_blockfile].ToString(), nFile, nHeight);
|
||||
}
|
||||
|
||||
// Do not propagate the return code. The flush concerns a previous block
|
||||
// and undo file that has already been written to. If a flush fails
|
||||
// here, and we crash, there is no expected additional block data
|
||||
// inconsistency arising from the flush failure here. However, the undo
|
||||
// data may be inconsistent after a crash if the flush is called during
|
||||
// a reindex. A flush error might also leave some of the data files
|
||||
// untrimmed.
|
||||
if (!FlushBlockFile(last_blockfile, !fKnown, finalize_undo)) {
|
||||
LogPrintLevel(BCLog::BLOCKSTORAGE, BCLog::Level::Warning,
|
||||
"Failed to flush previous block file %05i (finalize=%i, finalize_undo=%i) before opening new block file %05i\n",
|
||||
last_blockfile, !fKnown, finalize_undo, nFile);
|
||||
// Do not propagate the return code. The flush concerns a previous block
|
||||
// and undo file that has already been written to. If a flush fails
|
||||
// here, and we crash, there is no expected additional block data
|
||||
// inconsistency arising from the flush failure here. However, the undo
|
||||
// data may be inconsistent after a crash if the flush is called during
|
||||
// a reindex. A flush error might also leave some of the data files
|
||||
// untrimmed.
|
||||
if (!FlushBlockFile(last_blockfile, !fKnown, finalize_undo)) {
|
||||
LogPrintLevel(BCLog::BLOCKSTORAGE, BCLog::Level::Warning,
|
||||
"Failed to flush previous block file %05i (finalize=%i, finalize_undo=%i) before opening new block file %05i\n",
|
||||
last_blockfile, !fKnown, finalize_undo, nFile);
|
||||
}
|
||||
}
|
||||
// No undo data yet in the new file, so reset our undo-height tracking.
|
||||
m_blockfile_cursors[chain_type] = BlockfileCursor{nFile};
|
||||
|
||||
Reference in New Issue
Block a user