lotus/cmd/curio/config_new.go

58 lines
1.4 KiB
Go
Raw Normal View History

2024-02-02 11:09:12 +00:00
package main
import (
"fmt"
2024-02-11 13:08:54 +00:00
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
2024-02-02 11:09:12 +00:00
"github.com/filecoin-project/lotus/api"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/cmd/curio/deps"
2024-02-02 11:09:12 +00:00
"github.com/filecoin-project/lotus/node/repo"
)
var configNewCmd = &cli.Command{
Name: "new-cluster",
Usage: "Create new configuration for a new cluster",
2024-02-02 11:09:12 +00:00
ArgsUsage: "[SP actor address...]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "repo",
EnvVars: []string{"LOTUS_PATH"},
Hidden: true,
Value: "~/.lotus",
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 1 {
return xerrors.New("must specify at least one SP actor address. Use 'lotus-shed miner create' or use 'curio guided-setup'")
2024-02-02 11:09:12 +00:00
}
ctx := cctx.Context
db, err := deps.MakeDB(cctx)
if err != nil {
return err
}
full, closer, err := cliutil.GetFullNodeAPIV1(cctx)
if err != nil {
return xerrors.Errorf("connecting to full node: %w", err)
}
defer closer()
ainfo, err := cliutil.GetAPIInfo(cctx, repo.FullNode)
2024-02-02 11:09:12 +00:00
if err != nil {
return xerrors.Errorf("could not get API info for FullNode: %w", err)
2024-02-02 11:09:12 +00:00
}
token, err := full.AuthNew(ctx, api.AllPermissions)
2024-02-02 11:09:12 +00:00
if err != nil {
return err
}
return deps.CreateMinerConfig(ctx, full, db, cctx.Args().Slice(), fmt.Sprintf("%s:%s", string(token), ainfo.Addr))
2024-02-02 11:09:12 +00:00
},
}