Fix storageminer cli
This commit is contained in:
parent
549e7db12f
commit
322031d8e4
@ -23,7 +23,7 @@ var chainHeadCmd = &cli.Command{
|
||||
Name: "head",
|
||||
Usage: "Print chain head",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -51,7 +51,7 @@ var chainGetBlock = &cli.Command{
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ var clientImportCmd = &cli.Command{
|
||||
Name: "import",
|
||||
Usage: "Import data",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -44,7 +44,7 @@ var clientLocalCmd = &cli.Command{
|
||||
Name: "local",
|
||||
Usage: "List locally imported data",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -65,7 +65,7 @@ var clientDealCmd = &cli.Command{
|
||||
Name: "deal",
|
||||
Usage: "Initialize storage deal with a miner",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
16
cli/cmd.go
16
cli/cmd.go
@ -53,7 +53,21 @@ func getAPI(ctx *cli.Context, repoFlag string) (string, http.Header, error) {
|
||||
return "ws://" + addr + "/rpc/v0", headers, nil
|
||||
}
|
||||
|
||||
func GetAPI(ctx *cli.Context) (api.FullNode, error) {
|
||||
func GetAPI(ctx *cli.Context) (api.Common, error) {
|
||||
f := "repo"
|
||||
if ctx.String("storagerepo") != "" {
|
||||
f = "storagerepo"
|
||||
}
|
||||
|
||||
addr, headers, err := getAPI(ctx, f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return client.NewCommonRPC(addr, headers)
|
||||
}
|
||||
|
||||
func GetFullNodeAPI(ctx *cli.Context) (api.FullNode, error) {
|
||||
addr, headers, err := getAPI(ctx, "repo")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -22,7 +22,7 @@ var createMinerCmd = &cli.Command{
|
||||
return fmt.Errorf("must pass four arguments: worker address, owner address, sector size, peer ID")
|
||||
}
|
||||
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ var minerStart = &cli.Command{
|
||||
Name: "start",
|
||||
Usage: "start mining",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ var mpoolPending = &cli.Command{
|
||||
Name: "pending",
|
||||
Usage: "Get pending messages",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ var walletNew = &cli.Command{
|
||||
Name: "new",
|
||||
Usage: "Generate a new key of the given type (bls or secp256k1)",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -47,7 +47,7 @@ var walletList = &cli.Command{
|
||||
Name: "list",
|
||||
Usage: "List wallet address",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -69,7 +69,7 @@ var walletBalance = &cli.Command{
|
||||
Name: "balance",
|
||||
Usage: "get account balance",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := GetAPI(cctx)
|
||||
api, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ var initCmd = &cli.Command{
|
||||
|
||||
log.Info("Trying to connect to full node RPC")
|
||||
|
||||
api, err := lcli.GetAPI(cctx) // TODO: consider storing full node address in config
|
||||
api, err := lcli.GetFullNodeAPI(cctx) // TODO: consider storing full node address in config
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ var log = logging.Logger("main")
|
||||
const FlagStorageRepo = "storagerepo"
|
||||
|
||||
func main() {
|
||||
logging.SetLogLevel("*", "INFO")
|
||||
logging.SetLogLevel("*", "DEBUG")
|
||||
local := []*cli.Command{
|
||||
runCmd,
|
||||
initCmd,
|
||||
|
@ -28,7 +28,7 @@ var runCmd = &cli.Command{
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
nodeApi, err := lcli.GetAPI(cctx)
|
||||
nodeApi, err := lcli.GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -80,8 +80,6 @@ var runCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: libp2p node
|
||||
|
||||
log.Infof("Remote version %s", v)
|
||||
|
||||
rpcServer := jsonrpc.NewServer()
|
||||
|
Loading…
Reference in New Issue
Block a user