Skip to content

Commit

Permalink
fixed div by 0 exception
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Aug 17, 2023
1 parent a05e843 commit 260cb8a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions handlers/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ func buildEpochPageData(epoch uint64) (*models.EpochPageData, time.Duration) {
pageData.TotalVoted = dbEpoch.VotedTotal
pageData.SyncParticipation = float64(dbEpoch.SyncParticipation) * 100
pageData.ValidatorCount = dbEpoch.ValidatorCount
pageData.AverageValidatorBalance = dbEpoch.ValidatorBalance / dbEpoch.ValidatorCount

if dbEpoch.ValidatorCount > 0 {
pageData.AverageValidatorBalance = dbEpoch.ValidatorBalance / dbEpoch.ValidatorCount
}
if dbEpoch.Eligible > 0 {
pageData.TargetVoteParticipation = float64(dbEpoch.VotedTarget) * 100.0 / float64(dbEpoch.Eligible)
pageData.HeadVoteParticipation = float64(dbEpoch.VotedHead) * 100.0 / float64(dbEpoch.Eligible)
Expand Down

0 comments on commit 260cb8a

Please sign in to comment.