HomePhabricator

refactor, blockstorage: Generalize GetFirstStoredBlock

Description

refactor, blockstorage: Generalize GetFirstStoredBlock

Summary:

GetFirstStoredBlock is generalized to check for any data status with a
status mask that needs to be passed as a parameter. To reflect this the
function is also renamed to GetFirstBlock.

Co-authored-by: stickies-v <stickies-v@protonmail.com>

In our codebase the status mask is a private member of BlockStatus, but we can achieve the same thing by passing a test function that takes a BlockStatus and returns a bool.

Core  ->  Bitcoin ABC
GetFirstBlock(upper_block, BLOCK_HAVE_DATA, &lower_block)
    -> GetFirstBlock(upper_block, [](BlockStatus status) {return status.hasData();}, &lower_block)
GetFirstBlock(upper_block, BLOCK_HAVE_MASK, &lower_block)
    -> GetFirstBlock(upper_block, [](BlockStatus status) {return status.hasData() && status.hasUndo();}, &lower_block)

This is a partial backport of core#29668
https://github.com/bitcoin/bitcoin/pull/29668/commits/96b4facc912927305b06a233cb8b36e7e5964c08

Test Plan: ninja check-functional-extended

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17924

Details

Provenance
PiRKAuthored on Thu, Apr 10, 14:23
PiRKPushed on Mon, Apr 14, 10:58
Reviewer
Restricted Project
Differential Revision
D17924: refactor, blockstorage: Generalize GetFirstStoredBlock
Parents
rABCd9a585497775: [Automated] Update seeds
Branches
Unknown
Tags
Unknown