Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename HighestStaticFiles::min #13235

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/cli/commands/src/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> PruneComma
info!(target: "reth::cli", "Copying data from database to static files...");
let static_file_producer =
StaticFileProducer::new(provider_factory.clone(), prune_config.segments.clone());
let lowest_static_file_height = static_file_producer.lock().copy_to_static_files()?.min();
let lowest_static_file_height =
static_file_producer.lock().copy_to_static_files()?.min_block_num();
info!(target: "reth::cli", ?lowest_static_file_height, "Copied data from database to static files");

// Delete data which has been copied to static files.
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/stage/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C>
let highest_static_file_block = provider_factory
.static_file_provider()
.get_highest_static_files()
.max()
.max_block_num()
.filter(|highest_static_file_block| *highest_static_file_block > target);

// Execute a pipeline unwind if the start of the range overlaps the existing static
Expand Down
2 changes: 1 addition & 1 deletion crates/stages/api/src/pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl<N: ProviderNodeTypes> Pipeline<N> {
pub fn move_to_static_files(&self) -> RethResult<()> {
// Copies data from database to static files
let lowest_static_file_height =
self.static_file_producer.lock().copy_to_static_files()?.min();
self.static_file_producer.lock().copy_to_static_files()?.min_block_num();

// Deletes data which has been copied to static files.
if let Some(prune_tip) = lowest_static_file_height {
Expand Down
12 changes: 6 additions & 6 deletions crates/static-file/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ impl HighestStaticFiles {
}

/// Returns the minimum block of all segments.
pub fn min(&self) -> Option<u64> {
pub fn min_block_num(&self) -> Option<u64> {
[self.headers, self.transactions, self.receipts].iter().filter_map(|&option| option).min()
}

/// Returns the maximum block of all segments.
pub fn max(&self) -> Option<u64> {
pub fn max_block_num(&self) -> Option<u64> {
[self.headers, self.transactions, self.receipts].iter().filter_map(|&option| option).max()
}
}
Expand Down Expand Up @@ -154,11 +154,11 @@ mod tests {
HighestStaticFiles { headers: Some(300), receipts: Some(100), transactions: None };

// Minimum value among the available segments
assert_eq!(files.min(), Some(100));
assert_eq!(files.min_block_num(), Some(100));

let empty_files = HighestStaticFiles::default();
// No values, should return None
assert_eq!(empty_files.min(), None);
assert_eq!(empty_files.min_block_num(), None);
}

#[test]
Expand All @@ -167,11 +167,11 @@ mod tests {
HighestStaticFiles { headers: Some(300), receipts: Some(100), transactions: Some(500) };

// Maximum value among the available segments
assert_eq!(files.max(), Some(500));
assert_eq!(files.max_block_num(), Some(500));

let empty_files = HighestStaticFiles::default();
// No values, should return None
assert_eq!(empty_files.max(), None);
assert_eq!(empty_files.max_block_num(), None);
}

#[test]
Expand Down
Loading