Skip to content

Commit

Permalink
feat: getting cluster id
Browse files Browse the repository at this point in the history
  • Loading branch information
yahortsaryk committed Oct 7, 2023
1 parent fbcb9b7 commit e75b507
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pallets/ddc-nodes/src/cdn_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ impl<ProviderId> NodeTrait<ProviderId> for CDNNode<ProviderId> {
fn get_props<'a>(&'a self) -> NodePropsRef<'a> {
NodePropsRef::CDNPropsRef(&self.props)
}
fn get_cluster_id(&self) -> &Option<ClusterId> {
&self.cluster_id
}
fn get_type(&self) -> NodeType {
NodeType::CDN
}
Expand Down
8 changes: 8 additions & 0 deletions pallets/ddc-nodes/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{
cdn_node::{CDNNode, CDNNodeParams, CDNNodeProps, CDNNodePubKey},
pallet::Error,
storage_node::{StorageNode, StorageNodeParams, StorageNodeProps, StorageNodePubKey},
ClusterId,
};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
Expand Down Expand Up @@ -52,6 +53,7 @@ pub trait NodeTrait<ProviderId> {
fn get_pub_key<'a>(&'a self) -> NodePubKeyRef<'a>;
fn get_provider_id(&self) -> &ProviderId;
fn get_props<'a>(&'a self) -> NodePropsRef<'a>;
fn get_cluster_id(&self) -> &Option<ClusterId>;
fn get_type(&self) -> NodeType;
fn from_params(
provider_id: ProviderId,
Expand All @@ -78,6 +80,12 @@ impl<ProviderId> NodeTrait<ProviderId> for Node<ProviderId> {
Node::CDN(node) => node.get_props(),
}
}
fn get_cluster_id(&self) -> &Option<ClusterId> {
match &self {
Node::Storage(node) => node.get_cluster_id(),
Node::CDN(node) => node.get_cluster_id(),
}
}
fn get_type(&self) -> NodeType {
match &self {
Node::Storage(node) => node.get_type(),
Expand Down
3 changes: 3 additions & 0 deletions pallets/ddc-nodes/src/storage_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ impl<ProviderId> NodeTrait<ProviderId> for StorageNode<ProviderId> {
fn get_props<'a>(&'a self) -> NodePropsRef<'a> {
NodePropsRef::StoragePropsRef(&self.props)
}
fn get_cluster_id(&self) -> &Option<ClusterId> {
&self.cluster_id
}
fn get_type(&self) -> NodeType {
NodeType::Storage
}
Expand Down

0 comments on commit e75b507

Please sign in to comment.