Skip to content

Commit

Permalink
Refactor skipping format upgrades so it is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Nov 29, 2023
1 parent baaa738 commit d57efb7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions zebra-state/src/service/finalized_state/zebra_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,16 @@ impl ZebraDb {
// Log any format changes before opening the database, in case opening fails.
let format_change = DbFormatChange::open_database(format_version_in_code, disk_version);

// Always do format upgrades in production, but allow them to be skipped by the scanner
// (because it doesn't support them yet).
//
// TODO: Make scanner support format upgrades, then remove `shielded-scan` here.
let can_skip_format_upgrades = cfg!(test) || cfg!(feature = "shielded-scan");

// Open the database and do initial checks.
let mut db = ZebraDb {
config: Arc::new(config.clone()),
debug_skip_format_upgrades,
debug_skip_format_upgrades: can_skip_format_upgrades && debug_skip_format_upgrades,
format_change_handle: None,
// After the database directory is created, a newly created database temporarily
// changes to the default database version. Then we set the correct version in the
Expand All @@ -132,12 +138,7 @@ impl ZebraDb {

/// Launch any required format changes or format checks, and store their thread handle.
pub fn spawn_format_change(&mut self, format_change: DbFormatChange) {
// Always do format upgrades in production, but allow them to be skipped by the scanner
// (because it doesn't support them yet).
//
// TODO: Make scanner support format upgrades, then remove `shielded-scan` here.
let can_skip_format_upgrades = cfg!(test) || cfg!(feature = "shielded-scan");
if can_skip_format_upgrades && self.debug_skip_format_upgrades {
if self.debug_skip_format_upgrades {
return;
}

Expand Down

0 comments on commit d57efb7

Please sign in to comment.