Merge pull request #1765 from filecoin-project/fix/miner-info-div-zero

avoid dividing by zero if pset is empty
This commit is contained in:
Whyrusleeping 2020-05-16 12:48:53 -07:00 committed by GitHub
commit 9a0d0511c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,10 +102,14 @@ var infoCmd = &cli.Command{
if len(faults) == 0 { if len(faults) == 0 {
fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(mi.SectorSize))))) fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(mi.SectorSize)))))
} else { } 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", 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(secCounts.Pset-uint64(len(faults))), types.NewInt(uint64(mi.SectorSize)))),
types.SizeStr(types.BigMul(types.NewInt(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() fmt.Println()