Skip to content
Closed
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions pallets/file-bank/src/impls/receptionist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ impl<T: Config> Receptionist<T> {
pub fn fly_upload_file(file_hash: Hash, user_brief: UserBrief<T>) -> DispatchResult {
<File<T>>::try_mutate(&file_hash, |file_opt| -> DispatchResult {
let file = file_opt.as_mut().ok_or(Error::<T>::FileNonExistent)?;
let needed_space = SEGMENT_SIZE
.checked_mul(15).ok_or(Error::<T>::Overflow)?
.checked_div(10).ok_or(Error::<T>::Overflow)?
.checked_mul(file.segment_list.len() as u128).ok_or(Error::<T>::Overflow)?;
let segment_len = file.segment_list.len();
let needed_space = Pallet::<T>::cal_file_size(segment_len as u128);
ensure!(T::StorageHandle::get_user_avail_space(&user_brief.user, &user_brief.territory_name)? > needed_space, Error::<T>::InsufficientAvailableSpace);
T::StorageHandle::add_territory_used_space(&user_brief.user, &user_brief.territory_name, needed_space)?;

Expand Down
2 changes: 2 additions & 0 deletions pallets/file-bank/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ pub mod pallet {
}
}

<UserHoldFileList<T>>::insert(&acc, file_info_list);

ClearUserList::<T>::mutate(|target_list| {
target_list.retain(|temp_acc| temp_acc.0 != *acc);
});
Expand Down
2 changes: 1 addition & 1 deletion pallets/storage-handler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pallet-storage-handler"
authors = ["CESS LAB"]
version = "0.7.0"
version = "0.7.1"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/CESSProject/cess"
Expand Down
59 changes: 55 additions & 4 deletions pallets/storage-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,56 @@ pub mod pallet {
Ok(())
}

/// temporary solution
#[pallet::call_index(120)]
#[transactional]
#[pallet::weight(<T as pallet::Config>::WeightInfo::reactivate_territory())]
pub fn other_reactivate_territory(
origin: OriginFor<T>,
target_acc: AccountOf<T>,
territory_name: TerrName,
days: u32,
) -> DispatchResult {
let signer = ensure_signed(origin)?;
let sender = target_acc;

let territory = <Territory<T>>::try_get(&sender, &territory_name)
.map_err(|_| Error::<T>::NotHaveTerritory)?;

ensure!(territory.state == TerritoryState::Expired, Error::<T>::NotExpire);

let days_unit_price = <UnitPrice<T>>::try_get()
.map_err(|_e| Error::<T>::BugInvalid)?
.checked_div(&30u32.saturated_into())
.ok_or(Error::<T>::Overflow)?;

let gib_count = territory.total_space.checked_div(G_BYTE).ok_or(Error::<T>::Overflow)?;

let price = days_unit_price
.checked_mul(&days.saturated_into())
.ok_or(Error::<T>::Overflow)?
.checked_mul(&gib_count.saturated_into())
.ok_or(Error::<T>::Overflow)?;

ensure!(
<T as pallet::Config>::Currency::can_slash(&signer, price.clone()),
Error::<T>::InsufficientBalance
);

T::CessTreasuryHandle::send_to_sid(signer.clone(), price.clone())?;

Self::add_purchased_space(territory.total_space)?;
Self::initial_territory(sender.clone(), territory_name.clone(), days)?;

Self::deposit_event(Event::<T>::ReactivateTerritory {
name: territory_name,
days: days,
spend: price,
});

Ok(())
}

#[pallet::call_index(102)]
#[transactional]
#[pallet::weight(<T as pallet::Config>::WeightInfo::territory_consignment())]
Expand Down Expand Up @@ -834,7 +884,6 @@ pub mod pallet {
Ok(())
}


#[pallet::call_index(6)]
#[transactional]
#[pallet::weight(<T as pallet::Config>::WeightInfo::create_order())]
Expand All @@ -848,7 +897,7 @@ pub mod pallet {
// minute
expired: u32,
) -> DispatchResult {
let _ = ensure_signed(origin)?;
let sender = ensure_signed(origin)?;

let expired: BlockNumberFor<T> = (expired
.checked_mul(6).ok_or(Error::<T>::Overflow)?).saturated_into();
Expand Down Expand Up @@ -887,7 +936,7 @@ pub mod pallet {
};

let (seed, _) =
T::MyRandomness::random(&(T::RewardPalletId::get(), now).encode());
T::MyRandomness::random(&(T::RewardPalletId::get(), now, sender).encode());
let seed = match seed {
Some(v) => v,
None => Default::default(),
Expand Down Expand Up @@ -1214,7 +1263,9 @@ impl<T: Config> Pallet<T> {
let _ = <Territory<T>>::try_mutate(&acc, &territory_name, |t_opt| -> DispatchResult {
let t = t_opt.as_mut().ok_or(Error::<T>::Unexpected)?;
Self::sub_purchased_space(t.total_space)?;
t.state = TerritoryState::Expired;
if t.state == TerritoryState::Frozen {
t.state = TerritoryState::Expired;
}
Ok(())
});
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
Expand Down
2 changes: 1 addition & 1 deletion standalone/chain/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "Unlicense"
name = "cess-node-runtime"
repository = "https://github.com/CESSProject/cess"
version = "0.10.1"
version = "0.10.2"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand Down
2 changes: 1 addition & 1 deletion standalone/chain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 130,
spec_version: 131,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
Binary file added wasms/spec_100.wasm
Binary file not shown.