MCPcopy Create free account
hub / github.com/ElementsProject/elements / ReadBlockFromDisk

Function ReadBlockFromDisk

src/node/blockstorage.cpp:755–785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753}
754
755bool ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos, const Consensus::Params& consensusParams)
756{
757 block.SetNull();
758
759 // Open history file to read
760 CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
761 if (filein.IsNull())
762 return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
763
764 // Read block
765 try {
766 filein >> block;
767 }
768 catch (const std::exception& e) {
769 return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
770 }
771
772 // Check the header
773 const uint256 block_hash = block.GetHash();
774 if (block_hash != consensusParams.hashGenesisBlock &&
775 !CheckProof(block, consensusParams)) {
776 return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
777 }
778
779 // Signet only: check block solution
780 if (consensusParams.signet_blocks && !CheckSignetBlockSolution(block, consensusParams)) {
781 return error("ReadBlockFromDisk: Errors in block solution at %s", pos.ToString());
782 }
783
784 return true;
785}
786
787bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
788{

Callers 15

rest_blockFunction · 0.85
ProcessGetBlockDataMethod · 0.85
ProcessMessageMethod · 0.85
SendMessagesMethod · 0.85
DisconnectTipMethod · 0.85
ConnectTipMethod · 0.85
VerifyDBMethod · 0.85
RollforwardBlockMethod · 0.85
ReplayBlocksMethod · 0.85
LoadExternalBlockFileMethod · 0.85
NotifyBlockMethod · 0.85
ComputeFilterFunction · 0.85

Calls 9

OpenBlockFileFunction · 0.85
errorFunction · 0.85
CheckProofFunction · 0.85
CheckSignetBlockSolutionFunction · 0.85
SetNullMethod · 0.45
IsNullMethod · 0.45
ToStringMethod · 0.45
GetHashMethod · 0.45
GetBlockHashMethod · 0.45

Tested by 1

ComputeFilterFunction · 0.68