Skip to content

Commit

Permalink
0.7.4 bucket delete (#240)
Browse files Browse the repository at this point in the history
* feat: change the deletion criteria for bucket containers.

* refactor: adjusting the size of segments and fragments
  • Loading branch information
ytqaljn authored Oct 12, 2023
1 parent 0e2cdf5 commit 2fb5a0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
12 changes: 2 additions & 10 deletions c-pallets/file-bank/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub mod pallet {
// replaced
MinerPowerInsufficient,

IsZero,
NotEmpty,
//Multi consensus query restriction of off chain workers
Locked,

Expand Down Expand Up @@ -860,16 +860,8 @@ pub mod pallet {
ensure!(Self::check_permission(sender.clone(), owner.clone()), Error::<T>::NoPermission);
ensure!(<Bucket<T>>::contains_key(&owner, &name), Error::<T>::NonExistent);
let bucket = <Bucket<T>>::try_get(&owner, &name).map_err(|_| Error::<T>::Unexpected)?;
for file_hash in bucket.object_list.iter() {
let file = <File<T>>::try_get(file_hash).map_err(|_| Error::<T>::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::<T>::NotEmpty);

Self::remove_user_hold_file_list(file_hash, &owner)?;
}
<Bucket<T>>::remove(&owner, &name);
<UserBucketList<T>>::try_mutate(&owner, |bucket_list| -> DispatchResult {
let mut index = 0;
Expand Down
4 changes: 2 additions & 2 deletions primitives/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2fb5a0a

Please sign in to comment.