Page MenuHomePhabricator

init: Reset mempool and chainman via reconstruction
ClosedPublic

Authored by PiRK on Feb 1 2023, 14:05.

Details

Reviewers
sdulfari
Group Reviewers
Restricted Project
Commits
rABC8ddcf128cecf: init: Reset mempool and chainman via reconstruction
Summary

Fixes https://github.com/bitcoin/bitcoin/issues/22964

Previously, we used UnloadBlockIndex() in order to reset node.mempool
and node.chainman. However, that has proven to be fragile (see
https://github.com/bitcoin/bitcoin/issues/22964), and requires
UnloadBlockIndex and its callees to be updated manually for each member
that's introduced to the mempool and chainman classes.

In this commit, we stop using the UnloadBlockIndex function and we
simply reconstruct node.mempool and node.chainman.

Since PeerManager needs a valid reference to both node.mempool and
node.chainman, we also move PeerManager's construction via ::make to
after the chainstate activation sequence is complete.

There are no more callers to UnloadBlockIndex after this commit, so it
and its sole callees can be pruned.

This is a partial backport of core#22564
https://github.com/bitcoin/bitcoin/pull/22564/commits/5921b863e39e5c3997895ffee1c87159e37a5d6f

Depends on D13086 and D13081

Test Plan

ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable