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

Function ReadBlockFromDisk

src/validation.cpp:1105–1132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1103}
1104
1105bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams)
1106{
1107 block.SetNull();
1108
1109 // Open history file to read
1110 CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
1111 if (filein.IsNull())
1112 return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
1113
1114 // Read block
1115 try {
1116 filein >> block;
1117 }
1118 catch (const std::exception& e) {
1119 return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
1120 }
1121
1122 // Check Equihash solution
1123 bool postfork = block.nHeight >= (uint32_t)consensusParams.BTGHeight;
1124 if (postfork && !CheckEquihashSolution(&block, Params())) {
1125 return error("ReadBlockFromDisk: Errors in block header at %s (bad Equihash solution)", pos.ToString());
1126 }
1127 // Check the header
1128 if (!CheckProofOfWork(block.GetHash(), block.nBits, postfork, consensusParams))
1129 return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
1130
1131 return true;
1132}
1133
1134bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
1135{

Callers 15

rest_blockFunction · 0.85
ProcessGetBlockDataFunction · 0.85
ProcessMessageFunction · 0.85
SendMessagesMethod · 0.85
GetTransactionFunction · 0.85
DisconnectTipMethod · 0.85
ConnectTipMethod · 0.85
VerifyDBMethod · 0.85
RollforwardBlockMethod · 0.85
ReplayBlocksMethod · 0.85
LoadExternalBlockFileFunction · 0.85
NotifyBlockMethod · 0.85

Calls 12

OpenBlockFileFunction · 0.85
errorFunction · 0.85
CheckEquihashSolutionFunction · 0.85
CheckProofOfWorkFunction · 0.85
whatMethod · 0.80
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