Skip to content

Commit

Permalink
move BucketId to ddc-primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
Raid5594 committed Nov 6, 2023
1 parent f031ff8 commit f23f012
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pallets/ddc-customers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use codec::{Decode, Encode, HasCompact};

use ddc_primitives::ClusterId;
use ddc_primitives::{BucketId, ClusterId};
use frame_support::{
parameter_types,
traits::{Currency, DefensiveSaturating, ExistenceRequirement},
Expand Down Expand Up @@ -43,15 +43,15 @@ pub struct UnlockChunk<Balance: HasCompact> {

#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct Bucket<AccountId> {
bucket_id: u64,
bucket_id: BucketId,
owner_id: AccountId,
cluster_id: Option<ClusterId>,
public_availability: bool,
}

#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct BucketsDetails<Balance: HasCompact> {
pub bucket_id: u64,
pub bucket_id: BucketId,
pub amount: Balance,
}

Expand Down Expand Up @@ -165,19 +165,19 @@ pub mod pallet {
StorageMap<_, Identity, T::AccountId, AccountsLedger<T::AccountId, BalanceOf<T>>>;

#[pallet::type_value]
pub fn DefaultBucketCount<T: Config>() -> u64 {
0_u64
pub fn DefaultBucketCount<T: Config>() -> BucketId {
0
}
#[pallet::storage]
#[pallet::getter(fn buckets_count)]
pub type BucketsCount<T: Config> =
StorageValue<Value = u64, QueryKind = ValueQuery, OnEmpty = DefaultBucketCount<T>>;
StorageValue<Value = BucketId, QueryKind = ValueQuery, OnEmpty = DefaultBucketCount<T>>;

/// Map from bucket ID to to the bucket structure
#[pallet::storage]
#[pallet::getter(fn buckets)]
pub type Buckets<T: Config> =
StorageMap<_, Twox64Concat, u64, Bucket<T::AccountId>, OptionQuery>;
StorageMap<_, Twox64Concat, BucketId, Bucket<T::AccountId>, OptionQuery>;

#[pallet::event]
#[pallet::generate_deposit(pub(crate) fn deposit_event)]
Expand Down Expand Up @@ -269,7 +269,7 @@ pub mod pallet {
#[pallet::weight(10_000)]
pub fn allocate_bucket_to_cluster(
origin: OriginFor<T>,
bucket_id: u64,
bucket_id: BucketId,
cluster_id: ClusterId,
) -> DispatchResult {
let bucket_owner = ensure_signed(origin)?;
Expand Down
1 change: 1 addition & 0 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use sp_core::hash::H160;
use sp_runtime::{AccountId32, RuntimeDebug};

pub type ClusterId = H160;
pub type BucketId = u64;

#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo, PartialEq)]
Expand Down

0 comments on commit f23f012

Please sign in to comment.