add a market balance command, and a verbose mode for storage-deals list
This commit is contained in:
parent
9012fea2f6
commit
8774a7b2dd
44
cli/state.go
44
cli/state.go
@ -67,6 +67,7 @@ var stateCmd = &cli.Command{
|
|||||||
stateWaitMsgCmd,
|
stateWaitMsgCmd,
|
||||||
stateSearchMsgCmd,
|
stateSearchMsgCmd,
|
||||||
stateMinerInfo,
|
stateMinerInfo,
|
||||||
|
stateMarketCmd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1524,3 +1525,46 @@ var stateCircSupplyCmd = &cli.Command{
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var stateMarketCmd = &cli.Command{
|
||||||
|
Name: "market",
|
||||||
|
Usage: "Inspect the storage market actor",
|
||||||
|
Subcommands: []*cli.Command{
|
||||||
|
stateMarketBalanceCmd,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var stateMarketBalanceCmd = &cli.Command{
|
||||||
|
Name: "balance",
|
||||||
|
Usage: "Get the market balance (locked and escrowed) for a given account",
|
||||||
|
Action: func(cctx *cli.Context) error {
|
||||||
|
if !cctx.Args().Present() {
|
||||||
|
return ShowHelp(cctx, fmt.Errorf("must specify address to print market balance for"))
|
||||||
|
}
|
||||||
|
|
||||||
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer closer()
|
||||||
|
|
||||||
|
ctx := ReqContext(cctx)
|
||||||
|
|
||||||
|
ts, err := LoadTipSet(ctx, cctx, api)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
addr, err := address.NewFromString(cctx.Args().First())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
balance, err := api.StateMarketBalance(ctx, addr, ts.Key())
|
||||||
|
|
||||||
|
fmt.Printf("Escrow: %s\n", types.FIL(balance.Escrow))
|
||||||
|
fmt.Printf("Locked: %s\n", types.FIL(balance.Locked))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
@ -338,6 +338,12 @@ var dealsImportDataCmd = &cli.Command{
|
|||||||
var dealsListCmd = &cli.Command{
|
var dealsListCmd = &cli.Command{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "List all deals for this miner",
|
Usage: "List all deals for this miner",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "verbose",
|
||||||
|
Aliases: []string{"v"},
|
||||||
|
},
|
||||||
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := lcli.GetStorageMinerAPI(cctx)
|
api, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -354,15 +360,28 @@ var dealsListCmd = &cli.Command{
|
|||||||
|
|
||||||
w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
||||||
|
|
||||||
|
verbose := cctx.Bool("verbose")
|
||||||
|
|
||||||
|
if verbose {
|
||||||
|
_, _ = fmt.Fprintf(w, "ProposalCid\tDealId\tState\tClient\tSize\tPrice\tDuration\tMessage\n")
|
||||||
|
} else {
|
||||||
_, _ = fmt.Fprintf(w, "ProposalCid\tDealId\tState\tClient\tSize\tPrice\tDuration\n")
|
_, _ = fmt.Fprintf(w, "ProposalCid\tDealId\tState\tClient\tSize\tPrice\tDuration\n")
|
||||||
|
}
|
||||||
|
|
||||||
for _, deal := range deals {
|
for _, deal := range deals {
|
||||||
propcid := deal.ProposalCid.String()
|
propcid := deal.ProposalCid.String()
|
||||||
|
if !verbose {
|
||||||
propcid = "..." + propcid[len(propcid)-8:]
|
propcid = "..." + propcid[len(propcid)-8:]
|
||||||
|
}
|
||||||
|
|
||||||
fil := types.FIL(types.BigMul(deal.Proposal.StoragePricePerEpoch, types.NewInt(uint64(deal.Proposal.Duration()))))
|
fil := types.FIL(types.BigMul(deal.Proposal.StoragePricePerEpoch, types.NewInt(uint64(deal.Proposal.Duration()))))
|
||||||
|
|
||||||
_, _ = fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\t%s\t%s\n", propcid, deal.DealID, storagemarket.DealStates[deal.State], deal.Proposal.Client, units.BytesSize(float64(deal.Proposal.PieceSize)), fil, deal.Proposal.Duration())
|
_, _ = fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\t%s\t%s", propcid, deal.DealID, storagemarket.DealStates[deal.State], deal.Proposal.Client, units.BytesSize(float64(deal.Proposal.PieceSize)), fil, deal.Proposal.Duration())
|
||||||
|
if verbose {
|
||||||
|
_, _ = fmt.Fprintf(w, "\t%s", deal.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _ = fmt.Fprintln(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.Flush()
|
return w.Flush()
|
||||||
|
Loading…
Reference in New Issue
Block a user