mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
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:
@ -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 data_dir = self.env.datadir.clone().resolve_datadir(self.env.chain.chain());
|
||||||
let db_path = data_dir.db();
|
let db_path = data_dir.db();
|
||||||
let static_files_path = data_dir.static_files();
|
let static_files_path = data_dir.static_files();
|
||||||
|
let exex_wal_path = data_dir.exex_wal();
|
||||||
|
|
||||||
// ensure the provided datadir exist
|
// ensure the provided datadir exist
|
||||||
eyre::ensure!(
|
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 Environment { provider_factory, .. } = self.env.init::<N>(AccessRights::RW)?;
|
||||||
let tool = DbTool::new(provider_factory)?;
|
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) => {
|
Subcommands::Clear(command) => {
|
||||||
let Environment { provider_factory, .. } = self.env.init::<N>(AccessRights::RW)?;
|
let Environment { provider_factory, .. } = self.env.init::<N>(AccessRights::RW)?;
|
||||||
|
|||||||
@ -131,11 +131,12 @@ impl<N: ProviderNodeTypes> DbTool<N> {
|
|||||||
.map_err(|e| eyre::eyre!(e))
|
.map_err(|e| eyre::eyre!(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Drops the database and the static files at the given path.
|
/// Drops the database, the static files and ExEx WAL at the given paths.
|
||||||
pub fn drop(
|
pub fn drop<P: AsRef<Path>>(
|
||||||
&self,
|
&self,
|
||||||
db_path: impl AsRef<Path>,
|
db_path: P,
|
||||||
static_files_path: impl AsRef<Path>,
|
static_files_path: P,
|
||||||
|
exex_wal_path: P,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let db_path = db_path.as_ref();
|
let db_path = db_path.as_ref();
|
||||||
info!(target: "reth::cli", "Dropping database at {:?}", db_path);
|
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::remove_dir_all(static_files_path)?;
|
||||||
fs::create_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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user