Skip to content

Commit

Permalink
fix: checking cluster existence
Browse files Browse the repository at this point in the history
  • Loading branch information
yahortsaryk committed Oct 13, 2023
1 parent 5f2acaa commit 7c65f2e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pallets/ddc-clusters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub mod pallet {
#[pallet::error]
pub enum Error<T> {
ClusterAlreadyExists,
ClusterDoesNotExist,
ClusterParamsExceedsLimit,
AttemptToAddNonExistentNode,
}
Expand Down Expand Up @@ -82,6 +83,7 @@ pub mod pallet {
node_pub_key: NodePubKey,
) -> DispatchResult {
ensure_signed(origin)?;
ensure!(Clusters::<T>::contains_key(&cluster_id), Error::<T>::ClusterDoesNotExist);
let mut node = T::NodeRepository::get(node_pub_key.clone())
.map_err(|_| Error::<T>::AttemptToAddNonExistentNode)?;
node.set_cluster_id(cluster_id);
Expand Down

0 comments on commit 7c65f2e

Please sign in to comment.