diff --git a/grey/crates/grey-services/src/accumulation.rs b/grey/crates/grey-services/src/accumulation.rs index 14b871452..7718eab8e 100644 --- a/grey/crates/grey-services/src/accumulation.rs +++ b/grey/crates/grey-services/src/accumulation.rs @@ -382,13 +382,11 @@ pub fn integrate_preimages( } } -/// Collect the set of work-package hashes from accumulated reports (P function). +/// Collect the set of work-package hashes from the first `count` reports (P function). +/// +/// Delegates to [`grey_state::accumulate::package_hashes`] after truncating to `count`. pub fn accumulated_package_hashes(reports: &[WorkReport], count: usize) -> BTreeSet { - reports - .iter() - .take(count) - .map(|r| r.package_spec.package_hash) - .collect() + grey_state::accumulate::package_hashes(&reports[..count.min(reports.len())]) } #[cfg(test)] diff --git a/grey/crates/grey-state/src/accumulate.rs b/grey/crates/grey-state/src/accumulate.rs index 1f4d18348..d0903b023 100644 --- a/grey/crates/grey-state/src/accumulate.rs +++ b/grey/crates/grey-state/src/accumulate.rs @@ -220,7 +220,7 @@ fn partition_reports(reports: &[WorkReport]) -> (Vec, Vec BTreeSet { +pub fn package_hashes(reports: &[WorkReport]) -> BTreeSet { reports .iter() .map(|r| r.package_spec.package_hash)