Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.7.4 bucket delete #240

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading