Skip to content

Commit

Permalink
Merge pull request #459 from Cerebellum-Network/feat/dac-multi-cluster
Browse files Browse the repository at this point in the history
Supporting multiple clusters for DAC validation
  • Loading branch information
yahortsaryk authored Oct 25, 2024
2 parents 659d2a8 + 33b0438 commit 710b149
Show file tree
Hide file tree
Showing 12 changed files with 711 additions and 559 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions pallets/ddc-clusters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,13 @@ pub mod pallet {

Ok(())
}

fn get_last_validated_era(cluster_id: &ClusterId) -> Result<DdcEra, DispatchError> {
let cluster =
Clusters::<T>::try_get(cluster_id).map_err(|_| Error::<T>::ClusterDoesNotExist)?;

Ok(cluster.last_validated_era_id)
}
}

impl<T: Config> ClusterManager<T> for Pallet<T> {
Expand Down Expand Up @@ -980,6 +987,16 @@ pub mod pallet {
) -> Result<(), DispatchError> {
Self::do_validate_node(*cluster_id, node_pub_key.clone(), succeeded)
}

fn get_clusters(status: ClusterStatus) -> Result<Vec<ClusterId>, DispatchError> {
let mut clusters_ids = Vec::new();
for (cluster_id, cluster) in <Clusters<T>>::iter() {
if cluster.status == status {
clusters_ids.push(cluster_id);
}
}
Ok(clusters_ids)
}
}

impl<T: Config> ClusterCreator<T, BalanceOf<T>> for Pallet<T>
Expand Down
4 changes: 4 additions & 0 deletions pallets/ddc-customers/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ impl<T: Config> ClusterManager<T> for TestClusterManager {
) -> Result<(), DispatchError> {
unimplemented!()
}

fn get_clusters(_status: ClusterStatus) -> Result<Vec<ClusterId>, DispatchError> {
unimplemented!()
}
}

pub struct TestClusterCreator;
Expand Down
Loading

0 comments on commit 710b149

Please sign in to comment.