@@ -788,15 +788,14 @@ impl<T: Config> Pallet<T> {
788788 . voting_next
789789 . replace ( next_voting_solution_range) ;
790790
791- if let Some ( solution_range_for_rewards) = EnableRewardsBelowSolutionRange :: < T > :: get ( ) {
792- if next_solution_range <= solution_range_for_rewards {
791+ if let Some ( solution_range_for_rewards) = EnableRewardsBelowSolutionRange :: < T > :: get ( )
792+ && next_solution_range <= solution_range_for_rewards {
793793 EnableRewardsBelowSolutionRange :: < T > :: take ( ) ;
794794
795795 let next_block_number =
796796 frame_system:: Pallet :: < T > :: current_block_number ( ) + One :: one ( ) ;
797797 EnableRewards :: < T > :: put ( next_block_number) ;
798798 }
799- }
800799 } ) ;
801800
802801 EraStartSlot :: < T > :: put ( current_slot) ;
@@ -950,8 +949,8 @@ impl<T: Config> Pallet<T> {
950949 ) ;
951950
952951 // Update target slot for entropy injection once we know it
953- if let Some ( entropy_source_block_number) = maybe_entropy_source_block_number {
954- if let Some ( entropy_value) = entropy. get_mut ( & entropy_source_block_number) {
952+ if let Some ( entropy_source_block_number) = maybe_entropy_source_block_number
953+ && let Some ( entropy_value) = entropy. get_mut ( & entropy_source_block_number) {
955954 let target_slot = pre_digest
956955 . slot ( )
957956 . saturating_add ( pot_entropy_injection_delay) ;
@@ -973,7 +972,6 @@ impl<T: Config> Pallet<T> {
973972 PotSlotIterations :: < T > :: put ( pot_slot_iterations) ;
974973 }
975974 }
976- }
977975
978976 PotEntropy :: < T > :: put ( entropy. clone ( ) ) ;
979977 }
@@ -1014,14 +1012,13 @@ impl<T: Config> Pallet<T> {
10141012 }
10151013
10161014 // Clean up old values we'll no longer need
1017- if let Some ( entry) = entropy. first_entry ( ) {
1018- if let Some ( target_slot) = entry. get ( ) . target_slot
1015+ if let Some ( entry) = entropy. first_entry ( )
1016+ && let Some ( target_slot) = entry. get ( ) . target_slot
10191017 && target_slot < current_slot
10201018 {
10211019 entry. remove ( ) ;
10221020 PotEntropy :: < T > :: put ( entropy) ;
10231021 }
1024- }
10251022 }
10261023 }
10271024
@@ -1636,19 +1633,18 @@ fn check_vote<T: Config>(
16361633 . as_ref ( )
16371634 == Some ( & key) ;
16381635
1639- if !is_equivocating {
1640- if let Some ( ( _reward_address, signature) ) = ParentBlockVoters :: < T > :: get ( ) . get ( & key) {
1636+ if !is_equivocating
1637+ && let Some ( ( _reward_address, signature) ) = ParentBlockVoters :: < T > :: get ( ) . get ( & key) {
16411638 if signature != & signed_vote. signature {
16421639 is_equivocating = true ;
16431640 } else {
16441641 // The same vote should never be included more than once
16451642 return Err ( CheckVoteError :: DuplicateVote ) ;
16461643 }
16471644 }
1648- }
16491645
1650- if !is_equivocating {
1651- if let Some ( ( _reward_address, signature) ) =
1646+ if !is_equivocating
1647+ && let Some ( ( _reward_address, signature) ) =
16521648 CurrentBlockVoters :: < T > :: get ( ) . unwrap_or_default ( ) . get ( & key)
16531649 {
16541650 if signature != & signed_vote. signature {
@@ -1658,7 +1654,6 @@ fn check_vote<T: Config>(
16581654 return Err ( CheckVoteError :: DuplicateVote ) ;
16591655 }
16601656 }
1661- }
16621657
16631658 if pre_dispatch {
16641659 // During `pre_dispatch` call put farmer into the list of reward receivers.
@@ -1686,12 +1681,10 @@ fn check_vote<T: Config>(
16861681 CurrentBlockAuthorInfo :: < T > :: mutate ( |maybe_info| {
16871682 if let Some ( ( public_key, _sector_index, _piece_offset, _chunk, _slot, reward_address) ) =
16881683 maybe_info
1689- {
1690- if public_key == & offender {
1684+ && public_key == & offender {
16911685 // Revoke reward for block author
16921686 reward_address. take ( ) ;
16931687 }
1694- }
16951688 } ) ;
16961689
16971690 CurrentBlockVoters :: < T > :: mutate ( |current_reward_receivers| {
@@ -1778,11 +1771,10 @@ impl<T: Config> subspace_runtime_primitives::FindBlockRewardAddress<T::AccountId
17781771 CurrentBlockAuthorInfo :: < T > :: get ( ) . and_then (
17791772 |( _public_key, _sector_index, _piece_offset, _chunk, _slot, reward_address) | {
17801773 // Rewards might be disabled, in which case no block reward
1781- if let Some ( height) = EnableRewards :: < T > :: get ( ) {
1782- if frame_system:: Pallet :: < T > :: current_block_number ( ) >= height {
1774+ if let Some ( height) = EnableRewards :: < T > :: get ( )
1775+ && frame_system:: Pallet :: < T > :: current_block_number ( ) >= height {
17831776 return reward_address;
17841777 }
1785- }
17861778
17871779 None
17881780 } ,
@@ -1793,8 +1785,8 @@ impl<T: Config> subspace_runtime_primitives::FindBlockRewardAddress<T::AccountId
17931785impl < T : Config > subspace_runtime_primitives:: FindVotingRewardAddresses < T :: AccountId > for Pallet < T > {
17941786 fn find_voting_reward_addresses ( ) -> Vec < T :: AccountId > {
17951787 // Rewards might be disabled, in which case no voting reward
1796- if let Some ( height) = EnableRewards :: < T > :: get ( ) {
1797- if frame_system:: Pallet :: < T > :: current_block_number ( ) >= height {
1788+ if let Some ( height) = EnableRewards :: < T > :: get ( )
1789+ && frame_system:: Pallet :: < T > :: current_block_number ( ) >= height {
17981790 // It is possible that this is called during initialization when current block
17991791 // voters are already moved into parent block voters, handle it accordingly
18001792 return CurrentBlockVoters :: < T > :: get ( )
@@ -1803,7 +1795,6 @@ impl<T: Config> subspace_runtime_primitives::FindVotingRewardAddresses<T::Accoun
18031795 . filter_map ( |( reward_address, _signature) | reward_address)
18041796 . collect ( ) ;
18051797 }
1806- }
18071798
18081799 Vec :: new ( )
18091800 }
0 commit comments