HomePhabricator

blockstorage: Make m_block_index own CBlockIndex's

Description

blockstorage: Make m_block_index own CBlockIndex's

Summary:
Instead of having CBlockIndex's live on the heap, which requires manual
memory management, have them be owned by m_block_index. This means that
they will live and die with BlockManager.

A change to BlockManager::LookupBlockIndex:

  • Previously, it was a const member function returning a non-const CBlockIndex*
  • Now, there's are const and non-const versions of BlockManager::LookupBlockIndex returning a CBlockIndex with the same const-ness as the member function: (e.g. const CBlockIndex* LookupBlockIndex(...) const)

See next commit for some weirdness that this eliminates.

The range based for-loops are modernize (using auto + destructuring) in
a future commit.

This is a partial backport of core#24050
https://github.com/bitcoin/bitcoin/pull/24050/commits/bec86ae32683ac56b4e6ba9c9b7d21cfbdf4ac03
https://github.com/bitcoin/bitcoin/pull/24050/commits/c2a1655799c5d5dab9b14bd2a6b2d2296efd6964

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
Carl Dong <contact@carldong.me>Authored on Jan 8 2021, 23:56
PiRKCommitted on Jan 20 2023, 15:21
PiRKPushed on Jan 20 2023, 15:22
Reviewer
Restricted Project
Differential Revision
D12991: blockstorage: Make m_block_index own CBlockIndex's
Parents
rABCeaacbf0bb289: Consistently use args/argsman in init.cpp
Branches
Unknown
Tags
Unknown