diff options
author | Martin Zumsande <mzumsande@gmail.com> | 2024-03-25 14:11:03 -0400 |
---|---|---|
committer | Martin Zumsande <mzumsande@gmail.com> | 2024-03-25 14:49:06 -0400 |
commit | e57f951805b429534c75ec1e6b2a1f16ae24efb5 (patch) | |
tree | 32b646c79608623d819315223112b239e612f50b /src/validation.cpp | |
parent | 2e1c84b333dc744dec04b783dc77b24a55e528d8 (diff) | |
download | bitcoin-e57f951805b429534c75ec1e6b2a1f16ae24efb5.tar.xz |
init, validation: Fix -reindex option with an existing snapshot
This didn't work for two reasons:
1.) GetSnapshotCoinsDBPath() was used to retrieve the path.
This requires coins_views to exist, but the initialisation only happens later
(in CompleteChainstateInitialization) so the node hits an assert in
CCoinsViewDB& CoinsDB() and crashes.
2.) The snapshot was already activated, so it has the mempool attached.
Therefore, the mempool needs to be transferred back to the ibd
chainstate before deleting the snapshot chainstate.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 0feda3f8a5..45849be5cd 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -6140,13 +6140,14 @@ bool ChainstateManager::DeleteSnapshotChainstate() Assert(m_snapshot_chainstate); Assert(m_ibd_chainstate); - fs::path snapshot_datadir = GetSnapshotCoinsDBPath(*m_snapshot_chainstate); + fs::path snapshot_datadir = Assert(node::FindSnapshotChainstateDir(m_options.datadir)).value(); if (!DeleteCoinsDBFromDisk(snapshot_datadir, /*is_snapshot=*/ true)) { LogPrintf("Deletion of %s failed. Please remove it manually to continue reindexing.\n", fs::PathToString(snapshot_datadir)); return false; } m_active_chainstate = m_ibd_chainstate.get(); + m_active_chainstate->m_mempool = m_snapshot_chainstate->m_mempool; m_snapshot_chainstate.reset(); return true; } |