HomePhabricator

blockstorage: Separate reindexing from saving new blocks

Description

blockstorage: Separate reindexing from saving new blocks

Summary:
SaveBlockToDisk / FindBlockPos are used for two purposes, depending on whether they are called during reindexing (dbp set, fKnown = true) or in the "normal" case when adding new blocks (dbp == nullptr, fKnown = false).
The actual tasks are quite different

  • In normal mode, preparations for saving a new block are made, which is then saved: find the correct position on disk (maybe skipping to a new blk file), check for available disk space, update the blockfile info db, save the block.
  • during reindex, most of this is not necessary (the block is already on disk after all), only the blockfile info needs to rebuilt because reindex wiped the leveldb it's saved in.

Using one function with many conditional statements for this leads to code that is hard to read / understand and bug-prone.

This is a backport of core#29975

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
Martin Zumsande <mzumsande@gmail.com>Authored on Mar 20 2024, 19:08
PiRKCommitted on Fri, Nov 21, 10:28
PiRKPushed on Fri, Nov 21, 10:28
Reviewer
Restricted Project
Differential Revision
D18974: blockstorage: Separate reindexing from saving new blocks
Parents
rABCa45d4be8324c: [ecash-agora] Patch version bump for updated chronik-client and ecash-wallet…
Branches
Unknown
Tags
Unknown