aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index d9a0fce34f..6836498a64 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2914,6 +2914,7 @@ CBlockIndex* Chainstate::FindMostWorkChain()
while (pindexTest != pindexFailed) {
if (fFailedChain) {
pindexFailed->nStatus |= BLOCK_FAILED_CHILD;
+ m_blockman.m_dirty_blockindex.insert(pindexFailed);
} else if (fMissingData) {
// If we're missing data, then add back to m_blocks_unlinked,
// so that if the block arrives in the future we can try adding
@@ -4998,15 +4999,15 @@ static bool DeleteCoinsDBFromDisk(const fs::path db_path, bool is_snapshot)
if (is_snapshot) {
fs::path base_blockhash_path = db_path / node::SNAPSHOT_BLOCKHASH_FILENAME;
- if (fs::exists(base_blockhash_path)) {
- bool removed = fs::remove(base_blockhash_path);
- if (!removed) {
- LogPrintf("[snapshot] failed to remove file %s\n",
- fs::PathToString(base_blockhash_path));
+ try {
+ bool existed = fs::remove(base_blockhash_path);
+ if (!existed) {
+ LogPrintf("[snapshot] snapshot chainstate dir being removed lacks %s file\n",
+ fs::PathToString(node::SNAPSHOT_BLOCKHASH_FILENAME));
}
- } else {
- LogPrintf("[snapshot] snapshot chainstate dir being removed lacks %s file\n",
- fs::PathToString(node::SNAPSHOT_BLOCKHASH_FILENAME));
+ } catch (const fs::filesystem_error& e) {
+ LogPrintf("[snapshot] failed to remove file %s: %s\n",
+ fs::PathToString(base_blockhash_path), fsbridge::get_filesystem_error_message(e));
}
}
@@ -5411,7 +5412,7 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation(
"restart, the node will resume syncing from %d "
"without using any snapshot data. "
"Please report this incident to %s, including how you obtained the snapshot. "
- "The invalid snapshot chainstate has been left on disk in case it is "
+ "The invalid snapshot chainstate will be left on disk in case it is "
"helpful in diagnosing the issue that caused this error."),
PACKAGE_NAME, snapshot_tip_height, snapshot_base_height, snapshot_base_height, PACKAGE_BUGREPORT
);
@@ -5424,7 +5425,10 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation(
assert(!this->IsUsable(m_snapshot_chainstate.get()));
assert(this->IsUsable(m_ibd_chainstate.get()));
- m_snapshot_chainstate->InvalidateCoinsDBOnDisk();
+ auto rename_result = m_snapshot_chainstate->InvalidateCoinsDBOnDisk();
+ if (!rename_result) {
+ user_error = strprintf(Untranslated("%s\n%s"), user_error, util::ErrorString(rename_result));
+ }
shutdown_fnc(user_error);
};
@@ -5626,7 +5630,7 @@ bool IsBIP30Unspendable(const CBlockIndex& block_index)
(block_index.nHeight==91812 && block_index.GetBlockHash() == uint256S("0x00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f"));
}
-void Chainstate::InvalidateCoinsDBOnDisk()
+util::Result<void> Chainstate::InvalidateCoinsDBOnDisk()
{
AssertLockHeld(::cs_main);
// Should never be called on a non-snapshot chainstate.
@@ -5655,13 +5659,14 @@ void Chainstate::InvalidateCoinsDBOnDisk()
LogPrintf("%s: error renaming file '%s' -> '%s': %s\n",
__func__, src_str, dest_str, e.what());
- AbortNode(strprintf(
+ return util::Error{strprintf(_(
"Rename of '%s' -> '%s' failed. "
"You should resolve this by manually moving or deleting the invalid "
"snapshot directory %s, otherwise you will encounter the same error again "
- "on the next startup.",
- src_str, dest_str, src_str));
+ "on the next startup."),
+ src_str, dest_str, src_str)};
}
+ return {};
}
const CBlockIndex* ChainstateManager::GetSnapshotBaseBlock() const