Page MenuHomePhabricator

blockstorage: Separate reindexing from saving new blocks
ClosedPublic

Authored by PiRK on Thu, Nov 20, 16:14.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC9a73c1576529: 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