Skip to content

Commit

Permalink
fixing possible division by 0
Browse files Browse the repository at this point in the history
  • Loading branch information
raffaele-oplabs committed Oct 1, 2024
1 parent 9a97a8e commit b0317cf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion op-monitorism/faultproof_withdrawals/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ func (s *State) LogState(log log.Logger) {

func (s *State) GetPercentages() (uint64, uint64) {
blockToProcess := s.latestL1Height - s.nextL1Height
syncPercentage := uint64(math.Floor(100 - (float64(blockToProcess) / float64(s.latestL1Height) * 100)))
divisor := float64(s.latestL1Height) * 100
//checking to avoid division by 0
if divisor == 0 {
return 0, 0
}
syncPercentage := uint64(math.Floor(100 - (float64(blockToProcess) / divisor)))
return blockToProcess, syncPercentage
}

Expand Down

0 comments on commit b0317cf

Please sign in to comment.