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

Function WriteBlockToDisk

src/main.cpp:1565–1584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1563//
1564
1565bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart)
1566{
1567 // Open history file to append
1568 CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION);
1569 if (fileout.IsNull())
1570 return error("WriteBlockToDisk: OpenBlockFile failed");
1571
1572 // Write index header
1573 unsigned int nSize = fileout.GetSerializeSize(block);
1574 fileout << FLATDATA(messageStart) << nSize;
1575
1576 // Write block
1577 long fileOutPos = ftell(fileout.Get());
1578 if (fileOutPos < 0)
1579 return error("WriteBlockToDisk: ftell failed");
1580 pos.nPos = (unsigned int)fileOutPos;
1581 fileout << block;
1582
1583 return true;
1584}
1585
1586bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
1587{

Callers 2

AcceptBlockFunction · 0.85
InitBlockIndexFunction · 0.85

Calls 5

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

Tested by

no test coverage detected