diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 32b52f5e2..b2e5a9f73 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -142,9 +142,9 @@ var infoCmd = &cli.Command{ }, } -type stateMeta struct{ - i int - col color.Attribute +type stateMeta struct { + i int + col color.Attribute state sealing.SectorState } @@ -178,8 +178,8 @@ var stateList = []stateMeta{ func init() { for i, state := range stateList { stateOrder[state.state] = stateMeta{ - i: i, - col: state.col, + i: i, + col: state.col, } } } diff --git a/cmd/lotus-storage-miner/storage.go b/cmd/lotus-storage-miner/storage.go index 47a1a7729..18dd80dff 100644 --- a/cmd/lotus-storage-miner/storage.go +++ b/cmd/lotus-storage-miner/storage.go @@ -145,7 +145,7 @@ var storageListCmd = &cli.Command{ type fsInfo struct { stores.ID sectors []stores.Decl - stat stores.FsStat + stat stores.FsStat } sorted := make([]fsInfo, 0, len(st)) @@ -187,7 +187,7 @@ var storageListCmd = &cli.Command{ } ping := time.Now().Sub(pingStart) - usedPercent := (st.Capacity-st.Available)*100/st.Capacity + usedPercent := (st.Capacity - st.Available) * 100 / st.Capacity percCol := color.FgGreen switch { @@ -198,7 +198,7 @@ var storageListCmd = &cli.Command{ } var barCols = uint64(50) - set := (st.Capacity-st.Available)*barCols/st.Capacity + set := (st.Capacity - st.Available) * barCols / st.Capacity bar := strings.Repeat("|", int(set)) + strings.Repeat(" ", int(barCols-set)) fmt.Printf("\t[%s] %s/%s %s\n", color.New(percCol).Sprint(bar), diff --git a/cmd/lotus-storage-miner/workers.go b/cmd/lotus-storage-miner/workers.go index 408dc9b2f..8114b74e6 100644 --- a/cmd/lotus-storage-miner/workers.go +++ b/cmd/lotus-storage-miner/workers.go @@ -66,37 +66,36 @@ var workersListCmd = &cli.Command{ gpuUse = "" } - fmt.Printf("Worker %d, host %s\n", stat.id, color.MagentaString(stat.Info.Hostname)) var barCols = uint64(64) cpuBars := int(stat.CpuUse * barCols / stat.Info.Resources.CPUs) - cpuBar := strings.Repeat("|", cpuBars) + strings.Repeat(" ", int(barCols) - cpuBars) + cpuBar := strings.Repeat("|", cpuBars) + strings.Repeat(" ", int(barCols)-cpuBars) fmt.Printf("\tCPU: [%s] %d core(s) in use\n", color.GreenString(cpuBar), stat.CpuUse) - ramBarsRes := int(stat.Info.Resources.MemReserved*barCols/stat.Info.Resources.MemPhysical) - ramBarsUsed := int(stat.MemUsedMin*barCols/stat.Info.Resources.MemPhysical) + ramBarsRes := int(stat.Info.Resources.MemReserved * barCols / stat.Info.Resources.MemPhysical) + ramBarsUsed := int(stat.MemUsedMin * barCols / stat.Info.Resources.MemPhysical) ramBar := color.YellowString(strings.Repeat("|", ramBarsRes)) + color.GreenString(strings.Repeat("|", ramBarsUsed)) + - strings.Repeat(" ", int(barCols) - ramBarsUsed - ramBarsRes) + strings.Repeat(" ", int(barCols)-ramBarsUsed-ramBarsRes) - vmem := stat.Info.Resources.MemPhysical+stat.Info.Resources.MemSwap + vmem := stat.Info.Resources.MemPhysical + stat.Info.Resources.MemSwap - vmemBarsRes := int(stat.Info.Resources.MemReserved*barCols/vmem) - vmemBarsUsed := int(stat.MemUsedMax*barCols/vmem) + vmemBarsRes := int(stat.Info.Resources.MemReserved * barCols / vmem) + vmemBarsUsed := int(stat.MemUsedMax * barCols / vmem) vmemBar := color.YellowString(strings.Repeat("|", vmemBarsRes)) + color.GreenString(strings.Repeat("|", vmemBarsUsed)) + - strings.Repeat(" ", int(barCols) - vmemBarsUsed - vmemBarsRes) + strings.Repeat(" ", int(barCols)-vmemBarsUsed-vmemBarsRes) fmt.Printf("\tRAM: [%s] %d%% %s/%s\n", ramBar, - (stat.Info.Resources.MemReserved + stat.MemUsedMin)*100/stat.Info.Resources.MemPhysical, - types.SizeStr(types.NewInt(stat.Info.Resources.MemReserved + stat.MemUsedMin)), + (stat.Info.Resources.MemReserved+stat.MemUsedMin)*100/stat.Info.Resources.MemPhysical, + types.SizeStr(types.NewInt(stat.Info.Resources.MemReserved+stat.MemUsedMin)), types.SizeStr(types.NewInt(stat.Info.Resources.MemPhysical))) fmt.Printf("\tVMEM: [%s] %d%% %s/%s\n", vmemBar, - (stat.Info.Resources.MemReserved + stat.MemUsedMax)*100/vmem, - types.SizeStr(types.NewInt(stat.Info.Resources.MemReserved + stat.MemUsedMax)), + (stat.Info.Resources.MemReserved+stat.MemUsedMax)*100/vmem, + types.SizeStr(types.NewInt(stat.Info.Resources.MemReserved+stat.MemUsedMax)), types.SizeStr(types.NewInt(vmem))) for _, gpu := range stat.Info.Resources.GPUs { diff --git a/lib/jsonrpc/rpc_test.go b/lib/jsonrpc/rpc_test.go index 34d01f6a1..93fe2f948 100644 --- a/lib/jsonrpc/rpc_test.go +++ b/lib/jsonrpc/rpc_test.go @@ -275,7 +275,7 @@ func TestUnmarshalableResult(t *testing.T) { } type ChanHandler struct { - wait chan struct{} + wait chan struct{} ctxdone <-chan struct{} } @@ -436,7 +436,6 @@ func TestChanServerClose(t *testing.T) { require.Equal(t, false, ok) } - func TestServerChanLockClose(t *testing.T) { var client struct { Sub func(context.Context, int, int) (<-chan int, error)