From 4818d784325ee97bbd744ef281558540695f5328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 3 Aug 2022 11:06:05 +0200 Subject: [PATCH] cli: Put bitfield stats in 'proving deadline' behind a flag --- cmd/lotus-miner/proving.go | 55 +++++++++++++++++------------ documentation/en/cli-lotus-miner.md | 1 + 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/cmd/lotus-miner/proving.go b/cmd/lotus-miner/proving.go index c758176b0..5ff49c25f 100644 --- a/cmd/lotus-miner/proving.go +++ b/cmd/lotus-miner/proving.go @@ -301,6 +301,11 @@ var provingDeadlineInfoCmd = &cli.Command{ Aliases: []string{"n"}, Usage: "Print sector/fault numbers belonging to this deadline", }, + &cli.BoolFlag{ + Name: "bitfield", + Aliases: []string{"b"}, + Usage: "Print partition bitfield stats", + }, }, ArgsUsage: "", Action: func(cctx *cli.Context) error { @@ -366,32 +371,36 @@ var provingDeadlineInfoCmd = &cli.Command{ return err } - var ones, zeros, oneRuns, zeroRuns, invalid uint64 - for rit.HasNext() { - r, err := rit.NextRun() - if err != nil { - return xerrors.Errorf("next run: %w", err) + if cctx.Bool("bitfield") { + var ones, zeros, oneRuns, zeroRuns, invalid uint64 + for rit.HasNext() { + r, err := rit.NextRun() + if err != nil { + return xerrors.Errorf("next run: %w", err) + } + if !r.Valid() { + invalid++ + } + if r.Val { + ones += r.Len + oneRuns++ + } else { + zeros += r.Len + zeroRuns++ + } } - if !r.Valid() { - invalid++ - } - if r.Val { - ones += r.Len - oneRuns++ - } else { - zeros += r.Len - zeroRuns++ - } - } - var buf bytes.Buffer - if err := bf.MarshalCBOR(&buf); err != nil { - return err - } - sz := len(buf.Bytes()) - szstr := types.SizeStr(types.NewInt(uint64(sz))) + var buf bytes.Buffer + if err := bf.MarshalCBOR(&buf); err != nil { + return err + } + sz := len(buf.Bytes()) + szstr := types.SizeStr(types.NewInt(uint64(sz))) - fmt.Printf("\t%s Sectors:%s%d (bitfield - runs %d+%d=%d - %d 0s %d 1s - %d inv - %s %dB)\n", name, strings.Repeat(" ", 18-len(name)), count, zeroRuns, oneRuns, zeroRuns+oneRuns, zeros, ones, invalid, szstr, sz) + fmt.Printf("\t%s Sectors:%s%d (bitfield - runs %d+%d=%d - %d 0s %d 1s - %d inv - %s %dB)\n", name, strings.Repeat(" ", 18-len(name)), count, zeroRuns, oneRuns, zeroRuns+oneRuns, zeros, ones, invalid, szstr, sz) + } else { + fmt.Printf("\t%s Sectors:%s%d\n", name, strings.Repeat(" ", 18-len(name)), count) + } if cctx.Bool("sector-nums") { nums, err := bf.All(count) diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index 7b852a83b..883c66ae8 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -2068,6 +2068,7 @@ USAGE: lotus-miner proving deadline [command options] OPTIONS: + --bitfield, -b Print partition bitfield stats (default: false) --sector-nums, -n Print sector/fault numbers belonging to this deadline (default: false) ```