cli: Put bitfield stats in 'proving deadline' behind a flag
This commit is contained in:
parent
9a5ca5017b
commit
4818d78432
@ -301,6 +301,11 @@ var provingDeadlineInfoCmd = &cli.Command{
|
|||||||
Aliases: []string{"n"},
|
Aliases: []string{"n"},
|
||||||
Usage: "Print sector/fault numbers belonging to this deadline",
|
Usage: "Print sector/fault numbers belonging to this deadline",
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "bitfield",
|
||||||
|
Aliases: []string{"b"},
|
||||||
|
Usage: "Print partition bitfield stats",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ArgsUsage: "<deadlineIdx>",
|
ArgsUsage: "<deadlineIdx>",
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
@ -366,32 +371,36 @@ var provingDeadlineInfoCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var ones, zeros, oneRuns, zeroRuns, invalid uint64
|
if cctx.Bool("bitfield") {
|
||||||
for rit.HasNext() {
|
var ones, zeros, oneRuns, zeroRuns, invalid uint64
|
||||||
r, err := rit.NextRun()
|
for rit.HasNext() {
|
||||||
if err != nil {
|
r, err := rit.NextRun()
|
||||||
return xerrors.Errorf("next run: %w", err)
|
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
|
var buf bytes.Buffer
|
||||||
if err := bf.MarshalCBOR(&buf); err != nil {
|
if err := bf.MarshalCBOR(&buf); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sz := len(buf.Bytes())
|
sz := len(buf.Bytes())
|
||||||
szstr := types.SizeStr(types.NewInt(uint64(sz)))
|
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") {
|
if cctx.Bool("sector-nums") {
|
||||||
nums, err := bf.All(count)
|
nums, err := bf.All(count)
|
||||||
|
@ -2068,6 +2068,7 @@ USAGE:
|
|||||||
lotus-miner proving deadline [command options] <deadlineIdx>
|
lotus-miner proving deadline [command options] <deadlineIdx>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
|
--bitfield, -b Print partition bitfield stats (default: false)
|
||||||
--sector-nums, -n Print sector/fault numbers belonging to this deadline (default: false)
|
--sector-nums, -n Print sector/fault numbers belonging to this deadline (default: false)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user