mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-18 11:01:06 +00:00
Merge #5710: Add more information to errors in ReadBlockFromDisk
f5791c6 Add more information to errors in ReadBlockFromDisk (Wladimir J. van der Laan)
This commit is contained in:
commit
175d86e633
@ -48,6 +48,12 @@ struct CDiskBlockPos
|
|||||||
|
|
||||||
void SetNull() { nFile = -1; nPos = 0; }
|
void SetNull() { nFile = -1; nPos = 0; }
|
||||||
bool IsNull() const { return (nFile == -1); }
|
bool IsNull() const { return (nFile == -1); }
|
||||||
|
|
||||||
|
std::string ToString() const
|
||||||
|
{
|
||||||
|
return strprintf("CBlockDiskPos(nFile=%i, nPos=%i)", nFile, nPos);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BlockStatus {
|
enum BlockStatus {
|
||||||
|
@ -1199,19 +1199,19 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
|||||||
// Open history file to read
|
// Open history file to read
|
||||||
CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
|
CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
|
||||||
if (filein.IsNull())
|
if (filein.IsNull())
|
||||||
return error("ReadBlockFromDisk: OpenBlockFile failed");
|
return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
|
||||||
|
|
||||||
// Read block
|
// Read block
|
||||||
try {
|
try {
|
||||||
filein >> block;
|
filein >> block;
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
return error("%s: Deserialize or I/O error - %s", __func__, e.what());
|
return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the header
|
// Check the header
|
||||||
if (!CheckProofOfWork(block.GetHash(), block.nBits))
|
if (!CheckProofOfWork(block.GetHash(), block.nBits))
|
||||||
return error("ReadBlockFromDisk: Errors in block header");
|
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1221,7 +1221,8 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
|
|||||||
if (!ReadBlockFromDisk(block, pindex->GetBlockPos()))
|
if (!ReadBlockFromDisk(block, pindex->GetBlockPos()))
|
||||||
return false;
|
return false;
|
||||||
if (block.GetHash() != pindex->GetBlockHash())
|
if (block.GetHash() != pindex->GetBlockHash())
|
||||||
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index");
|
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
|
||||||
|
pindex->ToString(), pindex->GetBlockPos().ToString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user