| 7577 | |
| 7578 | |
| 7579 | bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock) |
| 7580 | { |
| 7581 | // Open history file to append |
| 7582 | CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION); |
| 7583 | if (fileout.IsNull()) |
| 7584 | return error("%s : OpenUndoFile failed", __func__); |
| 7585 | |
| 7586 | // Write index header |
| 7587 | unsigned int nSize = fileout.GetSerializeSize(blockundo); |
| 7588 | fileout << FLATDATA(Params().MessageStart()) << nSize; |
| 7589 | |
| 7590 | // Write undo data |
| 7591 | long fileOutPos = ftell(fileout.Get()); |
| 7592 | if (fileOutPos < 0) |
| 7593 | return error("%s : ftell failed", __func__); |
| 7594 | pos.nPos = (unsigned int)fileOutPos; |
| 7595 | fileout << blockundo; |
| 7596 | |
| 7597 | // calculate & write checksum |
| 7598 | CHashWriter hasher(SER_GETHASH, PROTOCOL_VERSION); |
| 7599 | hasher << hashBlock; |
| 7600 | hasher << blockundo; |
| 7601 | fileout << hasher.GetHash(); |
| 7602 | |
| 7603 | return true; |
| 7604 | } |
| 7605 | |
| 7606 | bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock) |
| 7607 | { |
no test coverage detected