Skip to content

Commit

Permalink
Don't delete dbs that can be reused
Browse files Browse the repository at this point in the history
  • Loading branch information
upbqdn committed Aug 7, 2024
1 parent 9c86135 commit 2a36e78
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion zebra-state/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tracing::Span;
use zebra_chain::parameters::Network;

use crate::{
constants::{DATABASE_FORMAT_VERSION_FILE_NAME, STATE_DATABASE_KIND},
constants::{DATABASE_FORMAT_VERSION_FILE_NAME, RESTORABLE_DB_VERSIONS, STATE_DATABASE_KIND},
state_database_format_version_in_code, BoxError,
};

Expand Down Expand Up @@ -317,6 +317,15 @@ fn check_and_delete_database(
return None;
}

// Don't delete databases that can be reused.
if RESTORABLE_DB_VERSIONS
.iter()
.map(|v| v - 1)
.any(|v| v == dir_major_version)
{
return None;
}

let outdated_path = entry.path();

// # Correctness
Expand Down

0 comments on commit 2a36e78

Please sign in to comment.