File tree 3 files changed +5
-3
lines changed
3 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -85,12 +85,14 @@ decl_module! {
85
85
pub struct Module <T : Trait > for enum Call where origin: T :: Origin {
86
86
87
87
fn on_initialize( now: T :: BlockNumber ) -> Weight {
88
+ let mut count = 0 ;
88
89
T :: Handler :: accumulate_reward( now, | pool, reward_to_accumulate | {
89
90
if !reward_to_accumulate. is_zero( ) {
91
+ count += 1 ;
90
92
Pools :: <T >:: mutate( pool, | pool_info | pool_info. total_rewards = pool_info. total_rewards. saturating_add( reward_to_accumulate) ) ;
91
93
}
92
94
} ) ;
93
- T :: WeightInfo :: on_initialize( Pools :: < T > :: iter ( ) . count( ) as u32 )
95
+ T :: WeightInfo :: on_initialize( count)
94
96
}
95
97
}
96
98
}
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ impl RewardHandler<AccountId, BlockNumber> for Handler {
79
79
80
80
fn accumulate_reward (
81
81
now : BlockNumber ,
82
- callback : impl Fn ( Self :: PoolId , Self :: Balance ) ,
82
+ mut callback : impl FnMut ( Self :: PoolId , Self :: Balance ) ,
83
83
) -> Vec < ( Self :: CurrencyId , Self :: Balance ) > {
84
84
if now % 2 == 0 {
85
85
let mut total_accumulated_rewards = 0 ;
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ pub trait RewardHandler<AccountId, BlockNumber> {
19
19
/// Accumulate rewards
20
20
fn accumulate_reward (
21
21
now : BlockNumber ,
22
- callback : impl Fn ( Self :: PoolId , Self :: Balance ) ,
22
+ callback : impl FnMut ( Self :: PoolId , Self :: Balance ) ,
23
23
) -> Vec < ( Self :: CurrencyId , Self :: Balance ) > ;
24
24
25
25
/// Payout the reward to `who`
You can’t perform that action at this time.
0 commit comments