Skip to content

Commit 5dbdd5d

Browse files
authored
divide by zero error fix (#683)
1 parent 5646470 commit 5dbdd5d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cmd/vote.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,18 @@ func (*UtilsStruct) HandleBlock(client *ethclient.Client, account types.Account,
178178
log.Error("Error in getting sRZR balance for staker: ", err)
179179
return
180180
}
181-
sRZRInEth, err := razorUtils.ConvertWeiToEth(sRZRBalance)
182-
if err != nil {
183-
log.Error(err)
184-
return
181+
182+
var sRZRInEth *big.Float
183+
if sRZRBalance.Cmp(big.NewInt(0)) == 0 {
184+
sRZRInEth = big.NewFloat(0)
185+
} else {
186+
sRZRInEth, err = razorUtils.ConvertWeiToEth(sRZRBalance)
187+
if err != nil {
188+
log.Error(err)
189+
return
190+
}
185191
}
192+
186193
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)
187194
if stakedAmount.Cmp(minStakeAmount) < 0 {
188195
log.Error("Stake is below minimum required. Cannot vote.")

0 commit comments

Comments
 (0)