mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Contracts: Refactor API to use WeightMeter (#2943)
Update the Contracts API to use `WeightMeter`, as it simplifies the code and makes it easier to reason about, rather than taking a mutable weight or returning a tuple with the weight consumed --------- Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -36,6 +36,7 @@ use frame_support::{
|
||||
fungible::{Mutate, MutateHold},
|
||||
tokens::{fungible::Inspect, Fortitude, Preservation},
|
||||
},
|
||||
weights::WeightMeter,
|
||||
BoundedBTreeMap, DefaultNoBound,
|
||||
};
|
||||
use frame_system::Pallet as System;
|
||||
@@ -125,7 +126,7 @@ impl<T: Config> MigrationStep for Migration<T> {
|
||||
T::WeightInfo::v15_migration_step()
|
||||
}
|
||||
|
||||
fn step(&mut self) -> (IsFinished, Weight) {
|
||||
fn step(&mut self, meter: &mut WeightMeter) -> IsFinished {
|
||||
let mut iter = if let Some(last_account) = self.last_account.take() {
|
||||
v14::ContractInfoOf::<T>::iter_from(v14::ContractInfoOf::<T>::hashed_key_for(
|
||||
last_account,
|
||||
@@ -234,10 +235,12 @@ impl<T: Config> MigrationStep for Migration<T> {
|
||||
// Store last key for next migration step
|
||||
self.last_account = Some(account);
|
||||
|
||||
(IsFinished::No, T::WeightInfo::v15_migration_step())
|
||||
meter.consume(T::WeightInfo::v15_migration_step());
|
||||
IsFinished::No
|
||||
} else {
|
||||
log::info!(target: LOG_TARGET, "Done Migrating Storage Deposits.");
|
||||
(IsFinished::Yes, T::WeightInfo::v15_migration_step())
|
||||
meter.consume(T::WeightInfo::v15_migration_step());
|
||||
IsFinished::Yes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user