mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 03:11:01 +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:
@@ -23,11 +23,10 @@ use crate::{
|
||||
weights::WeightInfo,
|
||||
Config, Pallet, TrieId, Weight, LOG_TARGET,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{pallet_prelude::*, storage_alias, weights::WeightMeter, DefaultNoBound};
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use sp_runtime::TryRuntimeError;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{pallet_prelude::*, storage_alias, DefaultNoBound};
|
||||
use sp_std::{marker::PhantomData, prelude::*};
|
||||
mod v10 {
|
||||
use super::*;
|
||||
@@ -79,9 +78,10 @@ impl<T: Config> MigrationStep for Migration<T> {
|
||||
T::WeightInfo::v11_migration_step(128)
|
||||
}
|
||||
|
||||
fn step(&mut self) -> (IsFinished, Weight) {
|
||||
fn step(&mut self, meter: &mut WeightMeter) -> IsFinished {
|
||||
let Some(old_queue) = v10::DeletionQueue::<T>::take() else {
|
||||
return (IsFinished::Yes, Weight::zero())
|
||||
meter.consume(T::WeightInfo::v11_migration_step(0));
|
||||
return IsFinished::Yes
|
||||
};
|
||||
let len = old_queue.len();
|
||||
|
||||
@@ -101,7 +101,8 @@ impl<T: Config> MigrationStep for Migration<T> {
|
||||
<DeletionQueueCounter<T>>::set(queue);
|
||||
}
|
||||
|
||||
(IsFinished::Yes, T::WeightInfo::v11_migration_step(len as u32))
|
||||
meter.consume(T::WeightInfo::v11_migration_step(len as u32));
|
||||
IsFinished::Yes
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
|
||||
Reference in New Issue
Block a user