mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 01:11:04 +00:00
on_initialize return weight consumed and default cost to default DispatchInfo instead of zero (#5382)
* frame update * doc * move offchain worker trait also * fix weigh merge * indentation * reorder for better git diff * comment * fix benchmark * remove test
This commit is contained in:
@@ -260,7 +260,7 @@ use sp_runtime::{Percent, ModuleId, RuntimeDebug,
|
||||
}
|
||||
};
|
||||
use frame_support::{decl_error, decl_module, decl_storage, decl_event, ensure, dispatch::DispatchResult};
|
||||
use frame_support::weights::SimpleDispatchInfo;
|
||||
use frame_support::weights::{SimpleDispatchInfo, Weight, WeighData};
|
||||
use frame_support::traits::{
|
||||
Currency, ReservableCurrency, Randomness, Get, ChangeMembers, BalanceStatus,
|
||||
ExistenceRequirement::AllowDeath
|
||||
@@ -1028,7 +1028,7 @@ decl_module! {
|
||||
Self::deposit_event(RawEvent::NewMaxMembers(max));
|
||||
}
|
||||
|
||||
fn on_initialize(n: T::BlockNumber) {
|
||||
fn on_initialize(n: T::BlockNumber) -> Weight {
|
||||
let mut members = vec![];
|
||||
|
||||
// Run a candidate/membership rotation
|
||||
@@ -1045,6 +1045,8 @@ decl_module! {
|
||||
}
|
||||
Self::rotate_challenge(&mut members);
|
||||
}
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,16 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
use frame_support::{impl_outer_origin, parameter_types, ord_parameter_types};
|
||||
use frame_support::{
|
||||
impl_outer_origin, parameter_types, ord_parameter_types, traits::{OnInitialize, OnFinalize}
|
||||
};
|
||||
use sp_core::H256;
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||
use sp_runtime::{
|
||||
Perbill,
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup, OnInitialize, OnFinalize},
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
};
|
||||
use frame_system::EnsureSignedBy;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user