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

Method CheckBlockDataAvailability

src/node/blockstorage.cpp:653–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653bool BlockManager::CheckBlockDataAvailability(const CBlockIndex& upper_block, const CBlockIndex& lower_block, BlockStatus block_status)
654{
655 if (!(upper_block.nStatus & block_status)) return false;
656 const auto& first_block = GetFirstBlock(upper_block, block_status, &lower_block);
657 // Special case: the genesis block has no undo data
658 if (block_status & BLOCK_HAVE_UNDO && lower_block.nHeight == 0 && first_block.nHeight == 1) {
659 // This might indicate missing data, or it could simply reflect the expected absence of undo data for the genesis block.
660 // To distinguish between the two, check if all required block data *except* undo is available up to the genesis block.
661 BlockStatus flags{block_status & ~BLOCK_HAVE_UNDO};
662 return first_block.pprev && first_block.pprev->nStatus & flags;
663 }
664 return &first_block == &lower_block;
665}
666
667// If we're using -prune with -reindex, then delete block files that will be ignored by the
668// reindex. Since reindexing works by starting at block file 0 and looping until a blockfile

Callers 2

StartIndexBackgroundSyncFunction · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80

Calls

no outgoing calls

Tested by 1

BOOST_FIXTURE_TEST_CASEFunction · 0.64