aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@pm.me>2023-05-03 15:39:51 -0400
committerJames O'Beirne <james.obeirne@pm.me>2023-09-30 06:38:43 -0400
commitc711ca186f8d8a28810be0beedcb615ddcf93163 (patch)
tree1f7d8f20f69004eaddec93e570d2cf6abd260472 /src/node
parentc93ef43e4fd4fbc1263cdc9e98ae5856830fe89e (diff)
downloadbitcoin-c711ca186f8d8a28810be0beedcb615ddcf93163.tar.xz
assumeutxo: remove snapshot during -reindex{-chainstate}
Removing a snapshot chainstate from disk (and memory) is consistent with existing reindex operations.
Diffstat (limited to 'src/node')
-rw-r--r--src/node/chainstate.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp
index ae1457a87e..16ca1d9156 100644
--- a/src/node/chainstate.cpp
+++ b/src/node/chainstate.cpp
@@ -185,7 +185,14 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
chainman.InitializeChainstate(options.mempool);
// Load a chain created from a UTXO snapshot, if any exist.
- chainman.DetectSnapshotChainstate(options.mempool);
+ bool has_snapshot = chainman.DetectSnapshotChainstate(options.mempool);
+
+ if (has_snapshot && (options.reindex || options.reindex_chainstate)) {
+ LogPrintf("[snapshot] deleting snapshot chainstate due to reindexing\n");
+ if (!chainman.DeleteSnapshotChainstate()) {
+ return {ChainstateLoadStatus::FAILURE_FATAL, Untranslated("Couldn't remove snapshot chainstate.")};
+ }
+ }
auto [init_status, init_error] = CompleteChainstateInitialization(chainman, cache_sizes, options);
if (init_status != ChainstateLoadStatus::SUCCESS) {