Assert DB compatibility

This commit is contained in:
dapplion
2025-04-04 18:32:19 -03:00
parent f6fa2380c7
commit 2384e9659b
6 changed files with 143 additions and 45 deletions

View File

@@ -33,4 +33,8 @@ impl CGCUpdates {
.push(update)
.map_err(|e| format!("Updates list full: {e:?}"))
}
pub fn iter(&self) -> impl Iterator<Item = (Slot, u64)> + '_ {
std::iter::once((Slot::new(0), self.initial_value)).chain(self.updates.iter().copied())
}
}

View File

@@ -104,6 +104,33 @@ pub fn compute_subnets_from_custody_group(
Ok(result)
}
pub fn compute_subnets_from_custody_groups<'a>(
custody_groups: &'a [CustodyIndex],
spec: &'a ChainSpec,
) -> impl Iterator<Item = DataColumnSubnetId> + 'a {
custody_groups
.iter()
.flat_map(|custody_group| {
compute_columns_for_custody_group(*custody_group, spec)
.expect("max(custody_groups) < number_of_custody_groups")
.map(|column_index| DataColumnSubnetId::from_column_index(column_index, spec))
})
.unique()
}
pub fn compute_columns_from_custody_groups<'a>(
custody_groups: &'a [CustodyIndex],
spec: &'a ChainSpec,
) -> impl Iterator<Item = ColumnIndex> + 'a {
custody_groups
.iter()
.flat_map(|custody_group| {
compute_columns_for_custody_group(*custody_group, spec)
.expect("max(custody_groups) < number_of_custody_groups")
})
.unique()
}
#[cfg(test)]
mod test {
use super::*;