Skip to content

Commit

Permalink
divide by zero error fix (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhar2807 authored Apr 15, 2022
1 parent 5646470 commit 5dbdd5d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cmd/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,18 @@ func (*UtilsStruct) HandleBlock(client *ethclient.Client, account types.Account,
log.Error("Error in getting sRZR balance for staker: ", err)
return
}
sRZRInEth, err := razorUtils.ConvertWeiToEth(sRZRBalance)
if err != nil {
log.Error(err)
return

var sRZRInEth *big.Float
if sRZRBalance.Cmp(big.NewInt(0)) == 0 {
sRZRInEth = big.NewFloat(0)
} else {
sRZRInEth, err = razorUtils.ConvertWeiToEth(sRZRBalance)
if err != nil {
log.Error(err)
return
}
}

log.Infof("Block: %d Epoch: %d State: %s Staker ID: %d Stake: %f sRZR Balance: %f Eth Balance: %f", blockNumber, epoch, utils.UtilsInterface.GetStateName(state), stakerId, actualStake, sRZRInEth, actualBalance)
if stakedAmount.Cmp(minStakeAmount) < 0 {
log.Error("Stake is below minimum required. Cannot vote.")
Expand Down

0 comments on commit 5dbdd5d

Please sign in to comment.