From 2fb5a0a9334d5e30e68738b78340e01089204351 Mon Sep 17 00:00:00 2001 From: Elden Young <59600396+ytqaljn@users.noreply.github.com> Date: Thu, 12 Oct 2023 09:01:50 +0800 Subject: [PATCH] 0.7.4 bucket delete (#240) * feat: change the deletion criteria for bucket containers. * refactor: adjusting the size of segments and fragments --- c-pallets/file-bank/src/lib.rs | 12 ++---------- primitives/common/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/c-pallets/file-bank/src/lib.rs b/c-pallets/file-bank/src/lib.rs index cfc55162..88eef4cc 100755 --- a/c-pallets/file-bank/src/lib.rs +++ b/c-pallets/file-bank/src/lib.rs @@ -216,7 +216,7 @@ pub mod pallet { // replaced MinerPowerInsufficient, - IsZero, + NotEmpty, //Multi consensus query restriction of off chain workers Locked, @@ -860,16 +860,8 @@ pub mod pallet { ensure!(Self::check_permission(sender.clone(), owner.clone()), Error::::NoPermission); ensure!(>::contains_key(&owner, &name), Error::::NonExistent); let bucket = >::try_get(&owner, &name).map_err(|_| Error::::Unexpected)?; - for file_hash in bucket.object_list.iter() { - let file = >::try_get(file_hash).map_err(|_| Error::::Unexpected)?; - if file.owner.len() > 1 { - Self::remove_file_owner(file_hash, &owner, true)?; - } else { - Self::remove_file_last_owner(file_hash, &owner, true)?; - } + ensure!(bucket.object_list == 0, Error::::NotEmpty); - Self::remove_user_hold_file_list(file_hash, &owner)?; - } >::remove(&owner, &name); >::try_mutate(&owner, |bucket_list| -> DispatchResult { let mut index = 0; diff --git a/primitives/common/src/lib.rs b/primitives/common/src/lib.rs index 052f67c4..f1220ea8 100644 --- a/primitives/common/src/lib.rs +++ b/primitives/common/src/lib.rs @@ -113,8 +113,8 @@ pub const M_BYTE: u128 = 1_048_576; pub const G_BYTE: u128 = 1_048_576 * 1024; pub const T_BYTE: u128 = 1_048_576 * 1024 * 1024; pub const IDLE_SEG_SIZE: u128 = M_BYTE * 64; -pub const SEGMENT_SIZE: u128 = M_BYTE * 16; -pub const FRAGMENT_SIZE: u128 = M_BYTE * 8; +pub const SEGMENT_SIZE: u128 = M_BYTE * 64; +pub const FRAGMENT_SIZE: u128 = M_BYTE * 16; // The number of fragments contained in a segment pub const FRAGMENT_COUNT: u32 = (SEGMENT_SIZE * 15 / 10 / FRAGMENT_SIZE) as u32; pub const ASSIGN_MINER_IDEAL_QUANTITY: u32 = FRAGMENT_COUNT;