MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / UndoWriteToDisk

Function UndoWriteToDisk

src/validation.cpp:1506–1531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1504namespace {
1505
1506bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart)
1507{
1508 // Open history file to append
1509 CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
1510 if (fileout.IsNull())
1511 return error("%s: OpenUndoFile failed", __func__);
1512
1513 // Write index header
1514 unsigned int nSize = GetSerializeSize(fileout, blockundo);
1515 fileout << messageStart << nSize;
1516
1517 // Write undo data
1518 long fileOutPos = ftell(fileout.Get());
1519 if (fileOutPos < 0)
1520 return error("%s: ftell failed", __func__);
1521 pos.nPos = (unsigned int)fileOutPos;
1522 fileout << blockundo;
1523
1524 // calculate & write checksum
1525 CHashWriter hasher(SER_GETHASH, PROTOCOL_VERSION);
1526 hasher << hashBlock;
1527 hasher << blockundo;
1528 fileout << hasher.GetHash();
1529
1530 return true;
1531}
1532
1533static bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex *pindex)
1534{

Callers 1

WriteUndoDataForBlockFunction · 0.85

Calls 6

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

Tested by

no test coverage detected