update size and unit
This commit is contained in:
parent
08ff772cf4
commit
66f8e348a2
@ -38,11 +38,13 @@ var infoCmd = &cli.Command{
|
||||
fmt.Printf("Miner: %s\n", maddr)
|
||||
|
||||
// Sector size
|
||||
size, err := api.StateMinerSectorSize(ctx, maddr, nil)
|
||||
sizeByte, err := api.StateMinerSectorSize(ctx, maddr, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Sector Size: %dKiB\n", size / 1024)
|
||||
|
||||
size, unit := getSizeAndUnit(sizeByte)
|
||||
fmt.Printf("Sector Size: %g %s\n", size, unit)
|
||||
|
||||
pow, err := api.StateMinerPower(ctx, maddr, nil)
|
||||
if err != nil {
|
||||
@ -69,6 +71,18 @@ var infoCmd = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
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 {
|
||||
TotalCount int
|
||||
SealingCount int
|
||||
|
Loading…
Reference in New Issue
Block a user