Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
return bucket list by account
Browse files Browse the repository at this point in the history
  • Loading branch information
Raid5594 committed Nov 27, 2022
1 parent 6d6748a commit 1babe29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bucket/ddc_bucket/bucket/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ impl DdcBucket {
(bucket_statuses, self.buckets.0.len())
}

pub fn message_bucket_list_for_account(&self, owner_id: AccountId) -> Vec<Bucket> {
self.buckets.0
.iter()
.filter(|bucket| bucket.owner_id == owner_id)
.cloned()
.collect()
}

pub fn bucket_calculate_status(&self, bucket_id: BucketId, bucket: Bucket) -> Result<BucketStatus> {
let mut writer_ids = self.buckets_perms.get_bucket_readers(bucket_id);
writer_ids.push(bucket.owner_id);
Expand Down
8 changes: 8 additions & 0 deletions bucket/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ pub mod ddc_bucket {
self.message_bucket_list(offset, limit, filter_owner_id)
}

/// Iterate through all buckets and return only those owned by owner
///
/// This method returns bucket struct, not the status
#[ink(message)]
pub fn bucket_list_for_account(&self, owner_id: AccountId) -> Vec<Bucket> {
self.message_bucket_list_for_account(owner_id)
}

/// Set availiablity of the bucket
#[ink(message)]
pub fn bucket_set_availability(&mut self, bucket_id: BucketId, public_availability: bool) -> () {
Expand Down

0 comments on commit 1babe29

Please sign in to comment.