mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
validation: Stricter assumeutxo error handling in LoadChainstate
Make LoadChainstate return an explicit error when snapshot validation succeeds, but there is an error trying to replace the background chainstate with the snapshot chainstate. Previously in this case LoadChainstate would trigger a shutdown and return INTERRUPTED, now it will return an actual error code. There's no real change to behavior other than error message being formatted a little differently. Motivation for this change is to replace error handling via callbacks with error handling via return value ahead of https://github.com/bitcoin/bitcoin/pull/27861
This commit is contained in:
parent
b3db18a012
commit
9047337d36
3 changed files with 4 additions and 3 deletions
|
@ -1530,7 +1530,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
}
|
||||
}
|
||||
|
||||
if (status == node::ChainstateLoadStatus::FAILURE_INCOMPATIBLE_DB || status == node::ChainstateLoadStatus::FAILURE_INSUFFICIENT_DBCACHE) {
|
||||
if (status == node::ChainstateLoadStatus::FAILURE_FATAL || status == node::ChainstateLoadStatus::FAILURE_INCOMPATIBLE_DB || status == node::ChainstateLoadStatus::FAILURE_INSUFFICIENT_DBCACHE) {
|
||||
return InitError(error);
|
||||
}
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
|
|||
} else if (snapshot_completion == SnapshotCompletionResult::SUCCESS) {
|
||||
LogPrintf("[snapshot] cleaning up unneeded background chainstate, then reinitializing\n");
|
||||
if (!chainman.ValidatedSnapshotCleanup()) {
|
||||
AbortNode("Background chainstate cleanup failed unexpectedly.");
|
||||
return {ChainstateLoadStatus::FAILURE_FATAL, Untranslated("Background chainstate cleanup failed unexpectedly.")};
|
||||
}
|
||||
|
||||
// Because ValidatedSnapshotCleanup() has torn down chainstates with
|
||||
|
|
|
@ -42,7 +42,8 @@ struct ChainstateLoadOptions {
|
|||
//! and exit cleanly in the interrupted case.
|
||||
enum class ChainstateLoadStatus {
|
||||
SUCCESS,
|
||||
FAILURE,
|
||||
FAILURE, //!< Generic failure which reindexing may fix
|
||||
FAILURE_FATAL, //!< Fatal error which should not prompt to reindex
|
||||
FAILURE_INCOMPATIBLE_DB,
|
||||
FAILURE_INSUFFICIENT_DBCACHE,
|
||||
INTERRUPTED,
|
||||
|
|
Loading…
Reference in a new issue