MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / GetRawBlockChecked

Function GetRawBlockChecked

src/rpc/blockchain.cpp:713–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

711}
712
713static std::vector<std::byte> GetRawBlockChecked(BlockManager& blockman, const CBlockIndex& blockindex)
714{
715 FlatFilePos pos{};
716 {
717 LOCK(cs_main);
718 CheckBlockDataAvailability(blockman, blockindex, /*check_for_undo=*/false);
719 pos = blockindex.GetBlockPos();
720 }
721
722 if (auto data{blockman.ReadRawBlock(pos)}) return std::move(*data);
723 // Block not found on disk. This shouldn't normally happen unless the block was
724 // pruned right after we released the lock above.
725 throw JSONRPCError(RPC_MISC_ERROR, "Block not found on disk");
726}
727
728static CBlockUndo GetUndoChecked(BlockManager& blockman, const CBlockIndex& blockindex)
729{

Callers 1

getblockFunction · 0.85

Calls 3

JSONRPCErrorFunction · 0.85
ReadRawBlockMethod · 0.80

Tested by

no test coverage detected