Skip to content

Commit

Permalink
Merge pull request #380 from irisnet/yuandu/fix-farm-genesis-validation
Browse files Browse the repository at this point in the history
fix: farm genesis validation
  • Loading branch information
aofengli committed Oct 11, 2023
2 parents 7a7772a + de46200 commit 3631ead
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/farm/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,17 @@ func ValidateGenesis(data GenesisState) error {
return fmt.Errorf("rewardPerBlock must be positive, but got %s", r.RewardPerBlock.String())
}

// If the unexpired pool rule has been updated, rewardPerShare will not be zero.
if !r.RewardPerShare.IsPositive() {
// No reward has ever been distributed.
if r.RemainingReward.Equal(r.TotalReward) {
continue
}
// The pool is expired and the reward is refund to the creator
if pool.EndHeight == pool.LastHeightDistrRewards {
continue
}

return fmt.Errorf("rewardPerShare must be positive, but got %s", r.RewardPerShare.String())
}
}
Expand Down

0 comments on commit 3631ead

Please sign in to comment.