mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
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.
This commit is contained in:
parent
aaaa3323f3
commit
fad59a2f0f
1 changed files with 3 additions and 8 deletions
|
@ -703,15 +703,10 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
|
||||||
{
|
{
|
||||||
const FlatFilePos pos{WITH_LOCK(::cs_main, return index.GetUndoPos())};
|
const FlatFilePos pos{WITH_LOCK(::cs_main, return index.GetUndoPos())};
|
||||||
|
|
||||||
if (pos.IsNull()) {
|
|
||||||
LogError("%s: no undo data available\n", __func__);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open history file to read
|
// Open history file to read
|
||||||
AutoFile filein{OpenUndoFile(pos, true)};
|
AutoFile filein{OpenUndoFile(pos, true)};
|
||||||
if (filein.IsNull()) {
|
if (filein.IsNull()) {
|
||||||
LogError("%s: OpenUndoFile failed\n", __func__);
|
LogError("%s: OpenUndoFile failed for %s\n", __func__, pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,13 +718,13 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
|
||||||
verifier >> blockundo;
|
verifier >> blockundo;
|
||||||
filein >> hashChecksum;
|
filein >> hashChecksum;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LogError("%s: Deserialize or I/O error - %s\n", __func__, e.what());
|
LogError("%s: Deserialize or I/O error - %s at %s\n", __func__, e.what(), pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify checksum
|
// Verify checksum
|
||||||
if (hashChecksum != verifier.GetHash()) {
|
if (hashChecksum != verifier.GetHash()) {
|
||||||
LogError("%s: Checksum mismatch\n", __func__);
|
LogError("%s: Checksum mismatch at %s\n", __func__, pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue