From 296ae4305fa224c285d7ee8c1d8facbb7f28ecfc Mon Sep 17 00:00:00 2001 From: duzy555666 <965876239@qq.com> Date: Mon, 28 Feb 2022 16:51:15 +0800 Subject: [PATCH] avoid panic --- cmd/lotus-miner/sealing.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/lotus-miner/sealing.go b/cmd/lotus-miner/sealing.go index 16b02f7bbe0..2f97c1e073c 100644 --- a/cmd/lotus-miner/sealing.go +++ b/cmd/lotus-miner/sealing.go @@ -39,9 +39,12 @@ func barString(total, y, g float64) string { yBars := int(math.Round(y / total * barCols)) gBars := int(math.Round(g / total * barCols)) eBars := int(barCols) - yBars - gBars - return color.YellowString(strings.Repeat("|", yBars)) + - color.GreenString(strings.Repeat("|", gBars)) + - strings.Repeat(" ", eBars) + var barString = color.YellowString(strings.Repeat("|", yBars)) + + color.GreenString(strings.Repeat("|", gBars)) + if eBars >= 0 { + barString += strings.Repeat(" ", eBars) + } + return barString } var sealingWorkersCmd = &cli.Command{