File tree Expand file tree Collapse file tree 3 files changed +5
-3
lines changed Expand file tree Collapse file tree 3 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -85,12 +85,14 @@ decl_module! {
8585 pub struct Module <T : Trait > for enum Call where origin: T :: Origin {
8686
8787 fn on_initialize( now: T :: BlockNumber ) -> Weight {
88+ let mut count = 0 ;
8889 T :: Handler :: accumulate_reward( now, | pool, reward_to_accumulate | {
8990 if !reward_to_accumulate. is_zero( ) {
91+ count += 1 ;
9092 Pools :: <T >:: mutate( pool, | pool_info | pool_info. total_rewards = pool_info. total_rewards. saturating_add( reward_to_accumulate) ) ;
9193 }
9294 } ) ;
93- T :: WeightInfo :: on_initialize( Pools :: < T > :: iter ( ) . count( ) as u32 )
95+ T :: WeightInfo :: on_initialize( count)
9496 }
9597 }
9698}
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ impl RewardHandler<AccountId, BlockNumber> for Handler {
7979
8080 fn accumulate_reward (
8181 now : BlockNumber ,
82- callback : impl Fn ( Self :: PoolId , Self :: Balance ) ,
82+ mut callback : impl FnMut ( Self :: PoolId , Self :: Balance ) ,
8383 ) -> Vec < ( Self :: CurrencyId , Self :: Balance ) > {
8484 if now % 2 == 0 {
8585 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> {
1919 /// Accumulate rewards
2020 fn accumulate_reward (
2121 now : BlockNumber ,
22- callback : impl Fn ( Self :: PoolId , Self :: Balance ) ,
22+ callback : impl FnMut ( Self :: PoolId , Self :: Balance ) ,
2323 ) -> Vec < ( Self :: CurrencyId , Self :: Balance ) > ;
2424
2525 /// Payout the reward to `who`
You can’t perform that action at this time.
0 commit comments