| 651 | } |
| 652 | |
| 653 | bool 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 |
no outgoing calls