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

Function WriteBlockToDisk

src/main.cpp:1847–1867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1845//
1846
1847bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos)
1848{
1849 // Open history file to append
1850 CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION);
1851 if (fileout.IsNull())
1852 return error("WriteBlockToDisk : OpenBlockFile failed");
1853
1854 // Write index header
1855 unsigned int nSize = fileout.GetSerializeSize(block);
1856 fileout << FLATDATA(Params().MessageStart()) << nSize;
1857
1858 // Write block
1859 long fileOutPos = ftell(fileout.Get());
1860 if (fileOutPos < 0)
1861 return error("WriteBlockToDisk : ftell failed");
1862
1863 pos.nPos = (unsigned int)fileOutPos;
1864 fileout << block;
1865
1866 return true;
1867}
1868
1869bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, int nHeight, const Consensus::Params& consensusParams, bool required)
1870{

Callers 2

AcceptBlockFunction · 0.85
InitBlockIndexFunction · 0.85

Calls 6

OpenBlockFileFunction · 0.85
errorFunction · 0.85
ParamsClass · 0.70
IsNullMethod · 0.45
GetSerializeSizeMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected