MCPcopy Create free account
hub / github.com/LUX-Core/lux / UndoReadFromDisk

Function UndoReadFromDisk

src/main.cpp:7606–7630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7604}
7605
7606bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock)
7607{
7608 // Open history file to read
7609 CAutoFile filein(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION);
7610 if (filein.IsNull())
7611 return error("%s : OpenBlockFile failed", __func__);
7612
7613 // Read block
7614 uint256 hashChecksum;
7615 try {
7616 filein >> blockundo;
7617 filein >> hashChecksum;
7618 } catch (std::exception& e) {
7619 return error("%s : Deserialize or I/O error - %s", __func__, e.what());
7620 }
7621
7622 // Verify checksum
7623 CHashWriter hasher(SER_GETHASH, PROTOCOL_VERSION);
7624 hasher << hashBlock;
7625 hasher << blockundo;
7626 if (hashChecksum != hasher.GetHash())
7627 return error("%s : Checksum mismatch", __func__);
7628
7629 return true;
7630}
7631
7632std::string CBlockFileInfo::ToString() const
7633{

Callers 2

DisconnectBlockFunction · 0.85
VerifyDBMethod · 0.85

Calls 5

OpenUndoFileFunction · 0.85
errorFunction · 0.85
IsNullMethod · 0.45
whatMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected