Merge pull request #542 from filcloud/fix/add-sectorsize-info
add sector size info
This commit is contained in:
commit
031c3e1174
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user