diff options
author | Carl Dong <contact@carldong.me> | 2021-09-13 17:02:55 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2022-04-27 11:09:00 -0400 |
commit | 5921b863e39e5c3997895ffee1c87159e37a5d6f (patch) | |
tree | 509012270fda170a061fea6c148447b97411d3ae /src/node | |
parent | 6e747e80e7094df0b5bee1eed57e57e82015d0ee (diff) |
init: Reset mempool and chainman via reconstruction
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.
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/chainstate.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index e43211402c..99615dea69 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -32,8 +32,6 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, chainman.m_total_coinstip_cache = nCoinCacheUsage; chainman.m_total_coinsdb_cache = nCoinDBCache; - UnloadBlockIndex(mempool, chainman); - auto& pblocktree{chainman.m_blockman.m_block_tree_db}; // new CBlockTreeDB tries to delete the existing file, which // fails if it's still open from the previous loop. Close it first: |