From f221c05a334b12363aca181479a74073aed0e2a2 Mon Sep 17 00:00:00 2001 From: wanghui Date: Thu, 7 Nov 2019 18:46:11 +0800 Subject: [PATCH 1/3] add sector size info --- cmd/lotus-storage-miner/info.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 436fc4686..287112494 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -37,6 +37,13 @@ var infoCmd = &cli.Command{ fmt.Printf("Miner: %s\n", maddr) + // Sector size + size, err := api.StateMinerSectorSize(ctx, maddr, nil) + if err != nil { + return err + } + fmt.Printf("Sector Size(Byte): %d\n", types.NewInt(size)) + pow, err := api.StateMinerPower(ctx, maddr, nil) if err != nil { return err @@ -56,7 +63,6 @@ var infoCmd = &cli.Command{ fmt.Println("Failed Sectors:\t", sinfo.FailedCount) // TODO: grab actr state / info - // * Sector size // * Sealed sectors (count / bytes) // * Power return nil From 08ff772cf41cd7746b2a3c05992cef6e011e6ec7 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 7 Nov 2019 19:33:44 +0800 Subject: [PATCH 2/3] Update cmd/lotus-storage-miner/info.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update sector size format Co-Authored-By: Ɓukasz Magiera --- cmd/lotus-storage-miner/info.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 287112494..05946f807 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -42,7 +42,7 @@ var infoCmd = &cli.Command{ if err != nil { return err } - fmt.Printf("Sector Size(Byte): %d\n", types.NewInt(size)) + fmt.Printf("Sector Size: %dKiB\n", size / 1024) pow, err := api.StateMinerPower(ctx, maddr, nil) if err != nil { From 66f8e348a21f24977b932401cf3aefbc0cfd6a4f Mon Sep 17 00:00:00 2001 From: wanghui Date: Thu, 7 Nov 2019 20:05:03 +0800 Subject: [PATCH 3/3] update size and unit --- cmd/lotus-storage-miner/info.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 05946f807..3ce7c0ff9 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -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