MCPcopy Create free account
hub / github.com/ElementsProject/elements / UndoWriteToDisk

Function UndoWriteToDisk

src/node/blockstorage.cpp:498–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496}
497
498static bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart)
499{
500 // Open history file to append
501 CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
502 if (fileout.IsNull()) {
503 return error("%s: OpenUndoFile failed", __func__);
504 }
505
506 // Write index header
507 unsigned int nSize = GetSerializeSize(blockundo, fileout.GetVersion());
508 fileout << messageStart << nSize;
509
510 // Write undo data
511 long fileOutPos = ftell(fileout.Get());
512 if (fileOutPos < 0) {
513 return error("%s: ftell failed", __func__);
514 }
515 pos.nPos = (unsigned int)fileOutPos;
516 fileout << blockundo;
517
518 // calculate & write checksum
519 CHashWriter hasher(SER_GETHASH, PROTOCOL_VERSION);
520 hasher << hashBlock;
521 hasher << blockundo;
522 fileout << hasher.GetHash();
523
524 return true;
525}
526
527bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
528{

Callers 1

WriteUndoDataForBlockMethod · 0.85

Calls 7

OpenUndoFileFunction · 0.85
errorFunction · 0.85
GetSerializeSizeFunction · 0.85
IsNullMethod · 0.45
GetVersionMethod · 0.45
GetMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected