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

Function WriteBlockToDisk

src/validation.cpp:1084–1103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1082//
1083
1084static bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart)
1085{
1086 // Open history file to append
1087 CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION);
1088 if (fileout.IsNull())
1089 return error("WriteBlockToDisk: OpenBlockFile failed");
1090
1091 // Write index header
1092 unsigned int nSize = GetSerializeSize(fileout, block);
1093 fileout << messageStart << nSize;
1094
1095 // Write block
1096 long fileOutPos = ftell(fileout.Get());
1097 if (fileOutPos < 0)
1098 return error("WriteBlockToDisk: ftell failed");
1099 pos.nPos = (unsigned int)fileOutPos;
1100 fileout << block;
1101
1102 return true;
1103}
1104
1105bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams)
1106{

Callers 1

SaveBlockToDiskFunction · 0.85

Calls 5

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

Tested by

no test coverage detected