add miner side commands and a few other goodies

This commit is contained in:
whyrusleeping
2020-03-03 18:49:00 -08:00
parent 52acfb88ee
commit 9169a073b6
6 changed files with 112 additions and 3 deletions
+1
View File
@@ -22,6 +22,7 @@ func main() {
lotuslog.SetupLogLevels()
local := []*cli.Command{
dealsCmd,
infoCmd,
initCmd,
pledgeSectorCmd,
+66
View File
@@ -1,10 +1,12 @@
package main
import (
"encoding/json"
"fmt"
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/ipfs/go-cid"
"gopkg.in/urfave/cli.v2"
)
@@ -33,3 +35,67 @@ var setPriceCmd = &cli.Command{
return api.SetPrice(ctx, types.BigInt(fp))
},
}
var dealsCmd = &cli.Command{
Name: "deals",
Usage: "interact with your deals",
Subcommands: []*cli.Command{
dealsImportDataCmd,
dealsListCmd,
},
}
var dealsImportDataCmd = &cli.Command{
Name: "import-data",
Usage: "Manually import data for a deal",
Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := lcli.DaemonContext(cctx)
if cctx.Args().Len() == 2 {
return fmt.Errorf("must specify proposal CID and file path")
}
propCid, err := cid.Decode(cctx.Args().Get(0))
if err != nil {
return err
}
fpath := cctx.Args().Get(1)
return api.DealsImportData(ctx, propCid, fpath)
},
}
var dealsListCmd = &cli.Command{
Name: "list",
Usage: "List all deals for this miner",
Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := lcli.DaemonContext(cctx)
deals, err := api.DealsList(ctx)
if err != nil {
return err
}
data, err := json.MarshalIndent(deals, "", " ")
if err != nil {
return err
}
fmt.Println(string(data))
return nil
},
}