feat: drop ExEx WAL on reth db drop (#11855)

Co-authored-by: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com>
This commit is contained in:
urb
2025-02-13 12:29:53 +00:00
committed by GitHub
parent 9dd90b5993
commit 2827447953
2 changed files with 11 additions and 5 deletions

View File

@ -68,6 +68,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C>
let data_dir = self.env.datadir.clone().resolve_datadir(self.env.chain.chain());
let db_path = data_dir.db();
let static_files_path = data_dir.static_files();
let exex_wal_path = data_dir.exex_wal();
// ensure the provided datadir exist
eyre::ensure!(
@ -124,7 +125,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C>
let Environment { provider_factory, .. } = self.env.init::<N>(AccessRights::RW)?;
let tool = DbTool::new(provider_factory)?;
tool.drop(db_path, static_files_path)?;
tool.drop(db_path, static_files_path, exex_wal_path)?;
}
Subcommands::Clear(command) => {
let Environment { provider_factory, .. } = self.env.init::<N>(AccessRights::RW)?;

View File

@ -131,11 +131,12 @@ impl<N: ProviderNodeTypes> DbTool<N> {
.map_err(|e| eyre::eyre!(e))
}
/// Drops the database and the static files at the given path.
pub fn drop(
/// Drops the database, the static files and ExEx WAL at the given paths.
pub fn drop<P: AsRef<Path>>(
&self,
db_path: impl AsRef<Path>,
static_files_path: impl AsRef<Path>,
db_path: P,
static_files_path: P,
exex_wal_path: P,
) -> Result<()> {
let db_path = db_path.as_ref();
info!(target: "reth::cli", "Dropping database at {:?}", db_path);
@ -146,6 +147,10 @@ impl<N: ProviderNodeTypes> DbTool<N> {
fs::remove_dir_all(static_files_path)?;
fs::create_dir_all(static_files_path)?;
let exex_wal_path = exex_wal_path.as_ref();
info!(target: "reth::cli", "Dropping ExEx WAL at {:?}", exex_wal_path);
fs::remove_dir_all(exex_wal_path)?;
Ok(())
}