From c80e8cb7d3cdd2d859fbbe19a00d85553fbae427 Mon Sep 17 00:00:00 2001 From: jennijuju Date: Wed, 28 Oct 2020 19:04:03 -0400 Subject: [PATCH 1/2] Add miner available balance and power info to state minor info --- cli/state.go | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/cli/state.go b/cli/state.go index d0fcc4f95..7b189644c 100644 --- a/cli/state.go +++ b/cli/state.go @@ -15,13 +15,13 @@ import ( "strings" "time" + "github.com/fatih/color" "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/multiformats/go-multiaddr" - "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" "github.com/libp2p/go-libp2p-core/peer" + "github.com/multiformats/go-multiaddr" "github.com/multiformats/go-multihash" "github.com/urfave/cli/v2" cbg "github.com/whyrusleeping/cbor-gen" @@ -107,13 +107,18 @@ var stateMinerInfo = &cli.Command{ return err } + availableBalance, err := api.StateMinerAvailableBalance(ctx, addr, ts.Key()) + if err != nil { + return xerrors.Errorf("getting miner available balance: %w", err) + } + fmt.Printf("Miner available balance: %sss\n", types.FIL(availableBalance)) fmt.Printf("Owner:\t%s\n", mi.Owner) fmt.Printf("Worker:\t%s\n", mi.Worker) for i, controlAddress := range mi.ControlAddresses { fmt.Printf("Control %d: \t%s\n", i, controlAddress) } + fmt.Printf("PeerID:\t%s\n", mi.PeerId) - fmt.Printf("SectorSize:\t%s (%d)\n", types.SizeStr(types.NewInt(uint64(mi.SectorSize))), mi.SectorSize) fmt.Printf("Multiaddrs: \t") for _, addr := range mi.Multiaddrs { a, err := multiaddr.NewMultiaddrBytes(addr) @@ -122,6 +127,26 @@ var stateMinerInfo = &cli.Command{ } fmt.Printf("%s ", a) } + + fmt.Printf("SectorSize:\t%s (%d)\n", types.SizeStr(types.NewInt(uint64(mi.SectorSize))), mi.SectorSize) + pow, err := api.StateMinerPower(ctx, addr, ts.Key()) + if err != nil { + return err + } + + rpercI := types.BigDiv(types.BigMul(pow.MinerPower.RawBytePower, types.NewInt(1000000)), pow.TotalPower.RawBytePower) + qpercI := types.BigDiv(types.BigMul(pow.MinerPower.QualityAdjPower, types.NewInt(1000000)), pow.TotalPower.QualityAdjPower) + + fmt.Printf("Byte Power: %s / %s (%0.4f%%)\n", + color.BlueString(types.SizeStr(pow.MinerPower.RawBytePower)), + types.SizeStr(pow.TotalPower.RawBytePower), + float64(rpercI.Int64())/10000) + + fmt.Printf("Actual Power: %s / %s (%0.4f%%)\n", + color.GreenString(types.DeciStr(pow.MinerPower.QualityAdjPower)), + types.DeciStr(pow.TotalPower.QualityAdjPower), + float64(qpercI.Int64())/10000) + fmt.Println() cd, err := api.StateMinerProvingDeadline(ctx, addr, ts.Key()) From e168f7a91725990dd82dfc3e25345750a83d487a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 29 Oct 2020 10:33:08 +0100 Subject: [PATCH 2/2] cli: miner-info review --- cli/state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/state.go b/cli/state.go index 7b189644c..cfa5dc5da 100644 --- a/cli/state.go +++ b/cli/state.go @@ -111,7 +111,7 @@ var stateMinerInfo = &cli.Command{ if err != nil { return xerrors.Errorf("getting miner available balance: %w", err) } - fmt.Printf("Miner available balance: %sss\n", types.FIL(availableBalance)) + fmt.Printf("Available Balance: %s\n", types.FIL(availableBalance)) fmt.Printf("Owner:\t%s\n", mi.Owner) fmt.Printf("Worker:\t%s\n", mi.Worker) for i, controlAddress := range mi.ControlAddresses {