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

Function ReadBlockFromDisk

src/main.cpp:1586–1608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1584}
1585
1586bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
1587{
1588 block.SetNull();
1589
1590 // Open history file to read
1591 CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
1592 if (filein.IsNull())
1593 return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
1594
1595 // Read block
1596 try {
1597 filein >> block;
1598 }
1599 catch (const std::exception& e) {
1600 return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
1601 }
1602
1603 // Check the header
1604 if (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus()))
1605 return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
1606
1607 return true;
1608}
1609
1610bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
1611{

Callers 11

getblockFunction · 0.85
rest_blockFunction · 0.85
readBlockFromDiskMethod · 0.85
gettxoutproofFunction · 0.85
GetTransactionFunction · 0.85
DisconnectTipFunction · 0.85
ConnectTipFunction · 0.85
LoadBlockIndexDBFunction · 0.85
VerifyDBMethod · 0.85
LoadExternalBlockFileFunction · 0.85

Calls 10

OpenBlockFileFunction · 0.85
errorFunction · 0.85
CheckProofOfWorkFunction · 0.85
GetBlockPosMethod · 0.80
ParamsClass · 0.70
SetNullMethod · 0.45
IsNullMethod · 0.45
ToStringMethod · 0.45
GetHashMethod · 0.45
GetBlockHashMethod · 0.45

Tested by

no test coverage detected