chore(db): remove generic from iter_static_files (#14542)

This commit is contained in:
DaniPopes
2025-02-17 19:03:47 +01:00
committed by GitHub
parent f69ca72dc5
commit bb6dec7ceb
2 changed files with 4 additions and 7 deletions

View File

@ -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 = let static_file_provider =
StaticFileProvider::<N>::read_only(data_dir.static_files(), false)?; StaticFileProvider::<N>::read_only(data_dir.static_files(), false)?;

View File

@ -26,8 +26,7 @@ type SortedStaticFiles =
/// Given the `static_files` directory path, it returns a list over the existing `static_files` /// 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 /// organized by [`StaticFileSegment`]. Each segment has a sorted list of block ranges and
/// transaction ranges as presented in the file configuration. /// transaction ranges as presented in the file configuration.
pub fn iter_static_files(path: impl AsRef<Path>) -> Result<SortedStaticFiles, NippyJarError> { pub fn iter_static_files(path: &Path) -> Result<SortedStaticFiles, NippyJarError> {
let path = path.as_ref();
if !path.exists() { if !path.exists() {
reth_fs_util::create_dir_all(path).map_err(|err| NippyJarError::Custom(err.to_string()))?; 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 mut static_files = SortedStaticFiles::default();
let entries = reth_fs_util::read_dir(path) let entries = reth_fs_util::read_dir(path)
.map_err(|err| NippyJarError::Custom(err.to_string()))? .map_err(|err| NippyJarError::Custom(err.to_string()))?
.filter_map(Result::ok) .filter_map(Result::ok);
.collect::<Vec<_>>();
for entry in entries { for entry in entries {
if entry.metadata().is_ok_and(|metadata| metadata.is_file()) { if entry.metadata().is_ok_and(|metadata| metadata.is_file()) {
if let Some((segment, _)) = 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() { for range_list in static_files.values_mut() {
// Sort by block end range. // 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) Ok(static_files)