mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(db): remove generic from iter_static_files (#14542)
This commit is contained in:
@ -172,7 +172,7 @@ impl Command {
|
||||
]);
|
||||
}
|
||||
|
||||
let static_files = iter_static_files(data_dir.static_files())?;
|
||||
let static_files = iter_static_files(&data_dir.static_files())?;
|
||||
let static_file_provider =
|
||||
StaticFileProvider::<N>::read_only(data_dir.static_files(), false)?;
|
||||
|
||||
|
||||
@ -26,8 +26,7 @@ type SortedStaticFiles =
|
||||
/// Given the `static_files` directory path, it returns a list over the existing `static_files`
|
||||
/// organized by [`StaticFileSegment`]. Each segment has a sorted list of block ranges and
|
||||
/// transaction ranges as presented in the file configuration.
|
||||
pub fn iter_static_files(path: impl AsRef<Path>) -> Result<SortedStaticFiles, NippyJarError> {
|
||||
let path = path.as_ref();
|
||||
pub fn iter_static_files(path: &Path) -> Result<SortedStaticFiles, NippyJarError> {
|
||||
if !path.exists() {
|
||||
reth_fs_util::create_dir_all(path).map_err(|err| NippyJarError::Custom(err.to_string()))?;
|
||||
}
|
||||
@ -35,9 +34,7 @@ pub fn iter_static_files(path: impl AsRef<Path>) -> Result<SortedStaticFiles, Ni
|
||||
let mut static_files = SortedStaticFiles::default();
|
||||
let entries = reth_fs_util::read_dir(path)
|
||||
.map_err(|err| NippyJarError::Custom(err.to_string()))?
|
||||
.filter_map(Result::ok)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
.filter_map(Result::ok);
|
||||
for entry in entries {
|
||||
if entry.metadata().is_ok_and(|metadata| metadata.is_file()) {
|
||||
if let Some((segment, _)) =
|
||||
@ -66,7 +63,7 @@ pub fn iter_static_files(path: impl AsRef<Path>) -> Result<SortedStaticFiles, Ni
|
||||
|
||||
for range_list in static_files.values_mut() {
|
||||
// Sort by block end range.
|
||||
range_list.sort_by(|a, b| a.0.end().cmp(&b.0.end()));
|
||||
range_list.sort_by_key(|(r, _)| r.end());
|
||||
}
|
||||
|
||||
Ok(static_files)
|
||||
|
||||
Reference in New Issue
Block a user