-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
4 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/urfave/cli/v2" | ||
"golang.org/x/xerrors" | ||
|
||
cliutil "github.com/filecoin-project/lotus/cli/util" | ||
"github.com/filecoin-project/lotus/cmd/curio/guidedsetup" | ||
"github.com/filecoin-project/lotus/node/repo" | ||
) | ||
|
||
var configMigrateCmd = &cli.Command{ | ||
Name: "from-miner", | ||
Usage: "Express a database config (for curio) from an existing miner.", | ||
Description: "Express a database config (for curio) from an existing miner.", | ||
Flags: []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: FlagMinerRepo, | ||
Aliases: []string{FlagMinerRepoDeprecation}, | ||
EnvVars: []string{"LOTUS_MINER_PATH", "LOTUS_STORAGE_PATH"}, | ||
Value: "~/.lotusminer", | ||
Usage: fmt.Sprintf("Specify miner repo path. flag(%s) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON", FlagMinerRepoDeprecation), | ||
}, | ||
&cli.StringFlag{ | ||
Name: "repo", | ||
EnvVars: []string{"LOTUS_PATH"}, | ||
Hidden: true, | ||
Value: "~/.lotus", | ||
}, | ||
&cli.StringFlag{ | ||
Name: "to-layer", | ||
Aliases: []string{"t"}, | ||
Usage: "The layer name for this data push. 'base' is recommended for single-miner setup.", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "overwrite", | ||
Aliases: []string{"o"}, | ||
Usage: "Use this with --to-layer to replace an existing layer", | ||
}, | ||
}, | ||
Action: fromMiner, | ||
} | ||
|
||
const ( | ||
FlagMinerRepo = "miner-repo" | ||
) | ||
|
||
const FlagMinerRepoDeprecation = "storagerepo" | ||
|
||
func fromMiner(cctx *cli.Context) (err error) { | ||
minerRepoPath := cctx.String(FlagMinerRepo) | ||
layerName := cctx.String("to-layer") | ||
overwrite := cctx.Bool("overwrite") | ||
|
||
// Populate API Key | ||
_, header, err := cliutil.GetRawAPI(cctx, repo.FullNode, "v0") | ||
if err != nil { | ||
return fmt.Errorf("cannot read API: %w", err) | ||
} | ||
|
||
ainfo, err := cliutil.GetAPIInfo(&cli.Context{}, repo.FullNode) | ||
if err != nil { | ||
return xerrors.Errorf(`could not get API info for FullNode: %w | ||
Set the environment variable to the value of "lotus auth api-info --perm=admin"`, err) | ||
} | ||
chainApiInfo := header.Get("Authorization")[7:] + ":" + ainfo.Addr | ||
_, err = guidedsetup.SaveConfigToLayer(minerRepoPath, layerName, overwrite, chainApiInfo) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters