mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 22:47:56 +00:00
Weight v1.5: Opaque Struct (#12138)
* initial idea * update frame_support * update a bunch more * add ord * adjust RuntimeDbWeight * frame_system builds * re-export * frame_support tests pass * frame_executive compile * frame_executive builds * frame_system tests passing * pallet-utility tests pass * fix a bunch of pallets * more * phragmen * state-trie-migration * scheduler and referenda * pallet-election-provider-multi-phase * aura * staking * more * babe * balances * bunch more * sudo * transaction-payment * asset-tx-payment * last pallets * fix alliance merge * fix node template runtime * fix pallet-contracts cc @athei * fix node runtime * fix compile on runtime-benchmarks feature * comment * fix frame-support-test * fix more tests * weight regex * frame system works * fix a bunch * more * more * more * more * more * more fixes * update templates * fix contracts benchmarks * Update lib.rs * Update lib.rs * fix ui * make scalar saturating mul const * more const functions * scalar div * refactor using constant functions * move impl * fix overhead template * use compactas * Update lib.rs
This commit is contained in:
@@ -23,13 +23,16 @@ use frame_support::traits::{ConstU32, ConstU64};
|
||||
|
||||
mod pallet_old {
|
||||
use frame_support::{
|
||||
decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter,
|
||||
decl_error, decl_event, decl_module, decl_storage,
|
||||
traits::Get,
|
||||
weights::{RefTimeWeight, Weight},
|
||||
Parameter,
|
||||
};
|
||||
use frame_system::ensure_root;
|
||||
|
||||
pub trait Config<I: Instance = DefaultInstance>: frame_system::Config {
|
||||
type SomeConst: Get<Self::Balance>;
|
||||
type Balance: Parameter + codec::HasCompact + From<u32> + Into<Weight> + Default;
|
||||
type Balance: Parameter + codec::HasCompact + From<u32> + Into<RefTimeWeight> + Default;
|
||||
type Event: From<Event<Self, I>> + Into<<Self as frame_system::Config>::Event>;
|
||||
}
|
||||
|
||||
@@ -62,7 +65,7 @@ mod pallet_old {
|
||||
fn deposit_event() = default;
|
||||
const SomeConst: T::Balance = T::SomeConst::get();
|
||||
|
||||
#[weight = <T::Balance as Into<Weight>>::into(new_value.clone())]
|
||||
#[weight = <T::Balance as Into<RefTimeWeight>>::into(new_value.clone())]
|
||||
fn set_dummy(origin, #[compact] new_value: T::Balance) {
|
||||
ensure_root(origin)?;
|
||||
|
||||
@@ -72,7 +75,7 @@ mod pallet_old {
|
||||
|
||||
fn on_initialize(_n: T::BlockNumber) -> Weight {
|
||||
<Dummy<T, I>>::put(T::Balance::from(10));
|
||||
10
|
||||
Weight::from_ref_time(10)
|
||||
}
|
||||
|
||||
fn on_finalize(_n: T::BlockNumber) {
|
||||
@@ -99,7 +102,7 @@ pub mod pallet {
|
||||
type Balance: Parameter
|
||||
+ codec::HasCompact
|
||||
+ From<u32>
|
||||
+ Into<Weight>
|
||||
+ Into<RefTimeWeight>
|
||||
+ Default
|
||||
+ MaybeSerializeDeserialize
|
||||
+ scale_info::StaticTypeInfo;
|
||||
@@ -116,7 +119,7 @@ pub mod pallet {
|
||||
impl<T: Config<I>, I: 'static> Hooks<T::BlockNumber> for Pallet<T, I> {
|
||||
fn on_initialize(_n: T::BlockNumber) -> Weight {
|
||||
<Dummy<T, I>>::put(T::Balance::from(10));
|
||||
10
|
||||
Weight::from_ref_time(10)
|
||||
}
|
||||
|
||||
fn on_finalize(_n: T::BlockNumber) {
|
||||
@@ -126,7 +129,7 @@ pub mod pallet {
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
#[pallet::weight(<T::Balance as Into<Weight>>::into(new_value.clone()))]
|
||||
#[pallet::weight(<T::Balance as Into<RefTimeWeight>>::into(new_value.clone()))]
|
||||
pub fn set_dummy(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] new_value: T::Balance,
|
||||
|
||||
Reference in New Issue
Block a user