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

Function UndoWriteToDisk

src/main.cpp:7579–7604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7577
7578
7579bool 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
7606bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock)
7607{

Callers 1

ConnectBlockFunction · 0.85

Calls 7

OpenUndoFileFunction · 0.85
errorFunction · 0.85
ParamsClass · 0.70
IsNullMethod · 0.45
GetSerializeSizeMethod · 0.45
GetMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected