Skip to content

Commit fad59a2

Browse files
author
MarcoFalke
committed
log: LogError with FlatFilePos in UndoReadFromDisk
These errors should never happen in normal operation. If they do, knowing the FlatFilePos may be useful to determine if data corruption happened. Also, handle the error pos.IsNull() as part of OpenUndoFile, because it may as well have happened due to data corruption. This mirrors the LogError behavior from ReadBlockFromDisk.
1 parent aaaa332 commit fad59a2

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/node/blockstorage.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -703,15 +703,10 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
703703
{
704704
const FlatFilePos pos{WITH_LOCK(::cs_main, return index.GetUndoPos())};
705705

706-
if (pos.IsNull()) {
707-
LogError("%s: no undo data available\n", __func__);
708-
return false;
709-
}
710-
711706
// Open history file to read
712707
AutoFile filein{OpenUndoFile(pos, true)};
713708
if (filein.IsNull()) {
714-
LogError("%s: OpenUndoFile failed\n", __func__);
709+
LogError("%s: OpenUndoFile failed for %s\n", __func__, pos.ToString());
715710
return false;
716711
}
717712

@@ -723,13 +718,13 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
723718
verifier >> blockundo;
724719
filein >> hashChecksum;
725720
} catch (const std::exception& e) {
726-
LogError("%s: Deserialize or I/O error - %s\n", __func__, e.what());
721+
LogError("%s: Deserialize or I/O error - %s at %s\n", __func__, e.what(), pos.ToString());
727722
return false;
728723
}
729724

730725
// Verify checksum
731726
if (hashChecksum != verifier.GetHash()) {
732-
LogError("%s: Checksum mismatch\n", __func__);
727+
LogError("%s: Checksum mismatch at %s\n", __func__, pos.ToString());
733728
return false;
734729
}
735730

0 commit comments

Comments
 (0)