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

Function WriteBlockToDisk

src/node/blockstorage.cpp:704–723  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702}
703
704static bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos, const CMessageHeader::MessageStartChars& messageStart)
705{
706 // Open history file to append
707 CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION);
708 if (fileout.IsNull())
709 return error("WriteBlockToDisk: OpenBlockFile failed");
710
711 // Write index header
712 unsigned int nSize = GetSerializeSize(block, fileout.GetVersion());
713 fileout << messageStart << nSize;
714
715 // Write block
716 long fileOutPos = ftell(fileout.Get());
717 if (fileOutPos < 0)
718 return error("WriteBlockToDisk: ftell failed");
719 pos.nPos = (unsigned int)fileOutPos;
720 fileout << block;
721
722 return true;
723}
724
725bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValidationState& state, CBlockIndex* pindex, const CChainParams& chainparams)
726{

Callers 1

SaveBlockToDiskMethod · 0.85

Calls 6

OpenBlockFileFunction · 0.85
errorFunction · 0.85
GetSerializeSizeFunction · 0.85
IsNullMethod · 0.45
GetVersionMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected