mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 15:41:02 +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:
@@ -20,7 +20,7 @@ use super::*;
|
||||
|
||||
use frame_system::RawOrigin;
|
||||
use frame_benchmarking::{benchmarks, account};
|
||||
use sp_runtime::traits::OnInitialize;
|
||||
use frame_support::traits::OnInitialize;
|
||||
|
||||
use crate::Module as Treasury;
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ use frame_support::traits::{
|
||||
use sp_runtime::{Permill, ModuleId, Percent, RuntimeDebug, traits::{
|
||||
Zero, EnsureOrigin, StaticLookup, AccountIdConversion, Saturating, Hash, BadOrigin
|
||||
}};
|
||||
use frame_support::{weights::SimpleDispatchInfo, traits::Contains};
|
||||
use frame_support::{weights::{Weight, WeighData, SimpleDispatchInfo}, traits::Contains};
|
||||
use codec::{Encode, Decode};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
@@ -553,11 +553,13 @@ decl_module! {
|
||||
Self::payout_tip(tip);
|
||||
}
|
||||
|
||||
fn on_initialize(n: T::BlockNumber) {
|
||||
fn on_initialize(n: T::BlockNumber) -> Weight {
|
||||
// Check to see if we should spend some funds!
|
||||
if (n % T::SpendPeriod::get()).is_zero() {
|
||||
Self::spend_funds();
|
||||
}
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
use super::*;
|
||||
|
||||
use frame_support::{assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use frame_support::traits::Contains;
|
||||
use frame_support::{
|
||||
assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight,
|
||||
traits::{Contains, OnInitialize}
|
||||
};
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
Perbill,
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, OnInitialize, IdentityLookup, BadOrigin},
|
||||
traits::{BlakeTwo256, IdentityLookup, BadOrigin},
|
||||
};
|
||||
|
||||
impl_outer_origin! {
|
||||
|
||||
Reference in New Issue
Block a user