| 7604 | } |
| 7605 | |
| 7606 | bool 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 | |
| 7632 | std::string CBlockFileInfo::ToString() const |
| 7633 | { |
no test coverage detected