Merge pull request #542 from filcloud/fix/add-sectorsize-info

add sector size info
This commit is contained in:
Whyrusleeping 2019-11-07 22:21:32 -08:00 committed by GitHub
commit 031c3e1174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,15 @@ var infoCmd = &cli.Command{
fmt.Printf("Miner: %s\n", maddr) fmt.Printf("Miner: %s\n", maddr)
// Sector size
sizeByte, err := api.StateMinerSectorSize(ctx, maddr, nil)
if err != nil {
return err
}
size, unit := getSizeAndUnit(sizeByte)
fmt.Printf("Sector Size: %g %s\n", size, unit)
pow, err := api.StateMinerPower(ctx, maddr, nil) pow, err := api.StateMinerPower(ctx, maddr, nil)
if err != nil { if err != nil {
return err return err
@ -56,13 +65,24 @@ var infoCmd = &cli.Command{
fmt.Println("Failed Sectors:\t", sinfo.FailedCount) fmt.Println("Failed Sectors:\t", sinfo.FailedCount)
// TODO: grab actr state / info // TODO: grab actr state / info
// * Sector size
// * Sealed sectors (count / bytes) // * Sealed sectors (count / bytes)
// * Power // * Power
return nil return nil
}, },
} }
var Units = []string{"B", "KiB", "MiB", "GiB"}
func getSizeAndUnit(size uint64) (float64, string) {
i := 0
unitSize := float64(size)
for unitSize >= 1024 && i < len(Units) - 1 {
unitSize = unitSize / 1024
i++
}
return unitSize, Units[i]
}
type SectorsInfo struct { type SectorsInfo struct {
TotalCount int TotalCount int
SealingCount int SealingCount int