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"
|
2024-03-15 21:38:13 +00:00
|
|
|
"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",
|
2024-03-06 09:41:37 +00:00
|
|
|
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 {
|
2024-04-03 20:00:14 +00:00
|
|
|
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()
|
|
|
|
|
2024-04-03 20:00:14 +00:00
|
|
|
ainfo, err := cliutil.GetAPIInfo(cctx, repo.FullNode)
|
2024-02-02 11:09:12 +00:00
|
|
|
if err != nil {
|
2024-04-03 20:00:14 +00:00
|
|
|
return xerrors.Errorf("could not get API info for FullNode: %w", err)
|
2024-02-02 11:09:12 +00:00
|
|
|
}
|
|
|
|
|
2024-04-03 20:00:14 +00:00
|
|
|
token, err := full.AuthNew(ctx, api.AllPermissions)
|
2024-02-02 11:09:12 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-04-03 20:00:14 +00:00
|
|
|
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
|
|
|
},
|
|
|
|
}
|