mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
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.
This commit is contained in:
parent
2e1c84b333
commit
e57f951805
1 changed files with 2 additions and 1 deletions
|
@ -6140,13 +6140,14 @@ bool ChainstateManager::DeleteSnapshotChainstate()
|
||||||
Assert(m_snapshot_chainstate);
|
Assert(m_snapshot_chainstate);
|
||||||
Assert(m_ibd_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)) {
|
if (!DeleteCoinsDBFromDisk(snapshot_datadir, /*is_snapshot=*/ true)) {
|
||||||
LogPrintf("Deletion of %s failed. Please remove it manually to continue reindexing.\n",
|
LogPrintf("Deletion of %s failed. Please remove it manually to continue reindexing.\n",
|
||||||
fs::PathToString(snapshot_datadir));
|
fs::PathToString(snapshot_datadir));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_active_chainstate = m_ibd_chainstate.get();
|
m_active_chainstate = m_ibd_chainstate.get();
|
||||||
|
m_active_chainstate->m_mempool = m_snapshot_chainstate->m_mempool;
|
||||||
m_snapshot_chainstate.reset();
|
m_snapshot_chainstate.reset();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue