From cf9e576028ce49f5f3fab7652bb66620ba5682aa Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 16 May 2020 11:35:24 -0700 Subject: [PATCH] avoid dividing by zero if pset is empty --- cmd/lotus-storage-miner/info.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index b2e5a9f73..6ab37d9b1 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -102,10 +102,14 @@ var infoCmd = &cli.Command{ if len(faults) == 0 { fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(mi.SectorSize))))) } else { + var faultyPercentage float64 + if secCounts.Pset != 0 { + faultyPercentage = float64(10000*uint64(len(faults))/secCounts.Pset) / 100. + } fmt.Printf("\tProving: %s (%s Faulty, %.2f%%)\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset-uint64(len(faults))), types.NewInt(uint64(mi.SectorSize)))), types.SizeStr(types.BigMul(types.NewInt(uint64(len(faults))), types.NewInt(uint64(mi.SectorSize)))), - float64(10000*uint64(len(faults))/secCounts.Pset)/100.) + faultyPercentage) } fmt.Println()