mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add fs-util::open (#12911)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8237,6 +8237,7 @@ dependencies = [
|
|||||||
"reth-downloaders",
|
"reth-downloaders",
|
||||||
"reth-errors",
|
"reth-errors",
|
||||||
"reth-execution-types",
|
"reth-execution-types",
|
||||||
|
"reth-fs-util",
|
||||||
"reth-network-p2p",
|
"reth-network-p2p",
|
||||||
"reth-node-builder",
|
"reth-node-builder",
|
||||||
"reth-node-core",
|
"reth-node-core",
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use reth_provider::{
|
|||||||
BlockNumReader, DatabaseProviderFactory, StaticFileProviderFactory, StaticFileWriter,
|
BlockNumReader, DatabaseProviderFactory, StaticFileProviderFactory, StaticFileWriter,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::{fs::File, io::BufReader, path::PathBuf, str::FromStr};
|
use std::{io::BufReader, path::PathBuf, str::FromStr};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
pub mod without_evm;
|
pub mod without_evm;
|
||||||
@ -115,8 +115,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> InitStateC
|
|||||||
|
|
||||||
info!(target: "reth::cli", "Initiating state dump");
|
info!(target: "reth::cli", "Initiating state dump");
|
||||||
|
|
||||||
let file = File::open(self.state)?;
|
let reader = BufReader::new(reth_fs_util::open(self.state)?);
|
||||||
let reader = BufReader::new(file);
|
|
||||||
|
|
||||||
let hash = init_from_state_dump(reader, &provider_rw, config.stages.etl)?;
|
let hash = init_from_state_dump(reader, &provider_rw, config.stages.etl)?;
|
||||||
|
|
||||||
|
|||||||
@ -210,6 +210,12 @@ impl FsPathError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Wrapper for [`File::open`].
|
||||||
|
pub fn open(path: impl AsRef<Path>) -> Result<File> {
|
||||||
|
let path = path.as_ref();
|
||||||
|
File::open(path).map_err(|err| FsPathError::open(err, path))
|
||||||
|
}
|
||||||
|
|
||||||
/// Wrapper for `std::fs::read_to_string`
|
/// Wrapper for `std::fs::read_to_string`
|
||||||
pub fn read_to_string(path: impl AsRef<Path>) -> Result<String> {
|
pub fn read_to_string(path: impl AsRef<Path>) -> Result<String> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
|
|||||||
@ -26,6 +26,7 @@ reth-execution-types.workspace = true
|
|||||||
reth-node-core.workspace = true
|
reth-node-core.workspace = true
|
||||||
reth-optimism-node.workspace = true
|
reth-optimism-node.workspace = true
|
||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
|
reth-fs-util.workspace = true
|
||||||
|
|
||||||
# so jemalloc metrics can be included
|
# so jemalloc metrics can be included
|
||||||
reth-node-metrics.workspace = true
|
reth-node-metrics.workspace = true
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use reth_provider::{
|
|||||||
BlockNumReader, ChainSpecProvider, DatabaseProviderFactory, StaticFileProviderFactory,
|
BlockNumReader, ChainSpecProvider, DatabaseProviderFactory, StaticFileProviderFactory,
|
||||||
StaticFileWriter,
|
StaticFileWriter,
|
||||||
};
|
};
|
||||||
use std::{fs::File, io::BufReader};
|
use std::io::BufReader;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
/// Initializes the database with the genesis block.
|
/// Initializes the database with the genesis block.
|
||||||
@ -70,7 +70,7 @@ impl<C: ChainSpecParser<ChainSpec = OpChainSpec>> InitStateCommandOp<C> {
|
|||||||
|
|
||||||
info!(target: "reth::cli", "Initiating state dump");
|
info!(target: "reth::cli", "Initiating state dump");
|
||||||
|
|
||||||
let reader = BufReader::new(File::open(self.init_state.state)?);
|
let reader = BufReader::new(reth_fs_util::open(self.init_state.state)?);
|
||||||
let hash = init_from_state_dump(reader, &provider_rw, config.stages.etl)?;
|
let hash = init_from_state_dump(reader, &provider_rw, config.stages.etl)?;
|
||||||
|
|
||||||
provider_rw.commit()?;
|
provider_rw.commit()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user