HomePhabricator

make GetFirstStoredBlock assert that 'start_block' always has data

Description

make GetFirstStoredBlock assert that 'start_block' always has data

Summary:
And transfer the responsibility of verifying whether 'start_block'
has data or not to the caller.

This is because the 'GetFirstStoredBlock' function responsibility
is to return the first block containing data. And the current
implementation can return 'start_block' when it has no data!. Which
is misleading at least.

Edge case behavior change:
Previously, if the block tip lacked data but all preceding blocks
contained data, there was no prune violation. And now, such
scenario will result in a prune violation.

This is a partial backport of core#27607
https://github.com/bitcoin/bitcoin/pull/27607/commits/c82ef91eae38f385d408b095ebbc8a180ce52ebb

Depends on D17746

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
furszy <matiasfurszyfer@protonmail.com>Authored on Jun 16 2023, 20:32
PiRKCommitted on Tue, Mar 4, 14:37
PiRKPushed on Tue, Mar 4, 14:37
Reviewer
Restricted Project
Differential Revision
D17747: make GetFirstStoredBlock assert that 'start_block' always has data
Parents
rABCf31a5561bd77: refactor: init indexes, decouple 'Start()' from the creation step
Branches
Unknown
Tags
Unknown