Skip to content

Commit e57f951

Browse files
committed
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.
1 parent 2e1c84b commit e57f951

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/validation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6140,13 +6140,14 @@ bool ChainstateManager::DeleteSnapshotChainstate()
61406140
Assert(m_snapshot_chainstate);
61416141
Assert(m_ibd_chainstate);
61426142

6143-
fs::path snapshot_datadir = GetSnapshotCoinsDBPath(*m_snapshot_chainstate);
6143+
fs::path snapshot_datadir = Assert(node::FindSnapshotChainstateDir(m_options.datadir)).value();
61446144
if (!DeleteCoinsDBFromDisk(snapshot_datadir, /*is_snapshot=*/ true)) {
61456145
LogPrintf("Deletion of %s failed. Please remove it manually to continue reindexing.\n",
61466146
fs::PathToString(snapshot_datadir));
61476147
return false;
61486148
}
61496149
m_active_chainstate = m_ibd_chainstate.get();
6150+
m_active_chainstate->m_mempool = m_snapshot_chainstate->m_mempool;
61506151
m_snapshot_chainstate.reset();
61516152
return true;
61526153
}

0 commit comments

Comments
 (0)