add path() to FinalizedState

This commit is contained in:
Alfredo Garcia 2021-06-18 11:23:01 -03:00 committed by Deirdre Connolly
parent 716fa23e86
commit 22cf3eed9e
1 changed files with 10 additions and 1 deletions

View File

@ -5,7 +5,7 @@ mod disk_format;
#[cfg(test)]
mod tests;
use std::{collections::HashMap, convert::TryInto, sync::Arc};
use std::{collections::HashMap, convert::TryInto, path::Path, sync::Arc};
use zebra_chain::transparent;
use zebra_chain::{
@ -73,6 +73,10 @@ impl FinalizedState {
debug_stop_at_height: config.debug_stop_at_height.map(block::Height),
};
// Make sure the database returned from the `db_config()` is always the same
// as the one returned by the `path()` method of the FinalizedState.
assert_eq!(new_state.path(), path);
if let Some(tip_height) = new_state.finalized_tip_height() {
if new_state.is_at_stop_height(tip_height) {
let debug_stop_at_height = new_state
@ -398,6 +402,11 @@ impl FinalizedState {
let _res = std::fs::remove_dir_all(path);
}
}
/// Returns the `Path` where the files used by this database are located.
pub fn path(&self) -> &Path {
self.db.path()
}
}
// Drop isn't guaranteed to run, such as when we panic, or if someone stored