Merge pull request #6936 from filecoin-project/feat/markets-env-var

support MARKETS_API_INFO env var, and markets-repo, markets-api-url CLI flags.
This commit is contained in:
raulk 2021-07-29 16:53:20 +01:00 committed by GitHub
commit c17a0c4fed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 231 additions and 115 deletions

View File

@ -113,7 +113,7 @@ var AuthApiInfoToken = &cli.Command{
ti, ok := cctx.App.Metadata["repoType"] ti, ok := cctx.App.Metadata["repoType"]
if !ok { if !ok {
log.Errorf("unknown repo type, are you sure you want to use GetAPI?") log.Errorf("unknown repo type, are you sure you want to use GetCommonAPI?")
ti = repo.FullNode ti = repo.FullNode
} }
t, ok := ti.(repo.RepoType) t, ok := ti.(repo.RepoType)
@ -128,7 +128,8 @@ var AuthApiInfoToken = &cli.Command{
// TODO: Log in audit log when it is implemented // TODO: Log in audit log when it is implemented
fmt.Printf("%s=%s:%s\n", cliutil.EnvForRepo(t), string(token), ainfo.Addr) currentEnv, _, _ := cliutil.EnvsForAPIInfos(t)
fmt.Printf("%s=%s:%s\n", currentEnv, string(token), ainfo.Addr)
return nil return nil
}, },
} }

View File

@ -44,7 +44,7 @@ func GetFullNodeServices(ctx *cli.Context) (ServicesAPI, error) {
var GetAPIInfo = cliutil.GetAPIInfo var GetAPIInfo = cliutil.GetAPIInfo
var GetRawAPI = cliutil.GetRawAPI var GetRawAPI = cliutil.GetRawAPI
var GetAPI = cliutil.GetAPI var GetAPI = cliutil.GetCommonAPI
var DaemonContext = cliutil.DaemonContext var DaemonContext = cliutil.DaemonContext
var ReqContext = cliutil.ReqContext var ReqContext = cliutil.ReqContext
@ -54,6 +54,7 @@ var GetFullNodeAPIV1 = cliutil.GetFullNodeAPIV1
var GetGatewayAPI = cliutil.GetGatewayAPI var GetGatewayAPI = cliutil.GetGatewayAPI
var GetStorageMinerAPI = cliutil.GetStorageMinerAPI var GetStorageMinerAPI = cliutil.GetStorageMinerAPI
var GetMarketsAPI = cliutil.GetMarketsAPI
var GetWorkerAPI = cliutil.GetWorkerAPI var GetWorkerAPI = cliutil.GetWorkerAPI
var CommonCommands = []*cli.Command{ var CommonCommands = []*cli.Command{

View File

@ -27,91 +27,114 @@ const (
metadataTraceContext = "traceContext" metadataTraceContext = "traceContext"
) )
// The flag passed on the command line with the listen address of the API // flagsForAPI returns flags passed on the command line with the listen address
// server (only used by the tests) // of the API server (only used by the tests), in the order of precedence they
func flagForAPI(t repo.RepoType) string { // should be applied for the requested kind of node.
func flagsForAPI(t repo.RepoType) []string {
switch t { switch t {
case repo.FullNode: case repo.FullNode:
return "api-url" return []string{"api-url"}
case repo.StorageMiner: case repo.StorageMiner:
return "miner-api-url" return []string{"miner-api-url"}
case repo.Worker: case repo.Worker:
return "worker-api-url" return []string{"worker-api-url"}
case repo.Markets:
// support split markets-miner and monolith deployments.
return []string{"markets-api-url", "miner-api-url"}
default: default:
panic(fmt.Sprintf("Unknown repo type: %v", t)) panic(fmt.Sprintf("Unknown repo type: %v", t))
} }
} }
func flagForRepo(t repo.RepoType) string { func flagsForRepo(t repo.RepoType) []string {
switch t { switch t {
case repo.FullNode: case repo.FullNode:
return "repo" return []string{"repo"}
case repo.StorageMiner: case repo.StorageMiner:
return "miner-repo" return []string{"miner-repo"}
case repo.Worker: case repo.Worker:
return "worker-repo" return []string{"worker-repo"}
case repo.Markets:
// support split markets-miner and monolith deployments.
return []string{"markets-repo", "miner-repo"}
default: default:
panic(fmt.Sprintf("Unknown repo type: %v", t)) panic(fmt.Sprintf("Unknown repo type: %v", t))
} }
} }
func EnvForRepo(t repo.RepoType) string { // EnvsForAPIInfos returns the environment variables to use in order of precedence
// to determine the API endpoint of the specified node type.
//
// It returns the current variables and deprecated ones separately, so that
// the user can log a warning when deprecated ones are found to be in use.
func EnvsForAPIInfos(t repo.RepoType) (primary string, fallbacks []string, deprecated []string) {
switch t { switch t {
case repo.FullNode: case repo.FullNode:
return "FULLNODE_API_INFO" return "FULLNODE_API_INFO", nil, nil
case repo.StorageMiner: case repo.StorageMiner:
return "MINER_API_INFO" // TODO remove deprecated deprecation period
return "MINER_API_INFO", nil, []string{"STORAGE_API_INFO"}
case repo.Worker: case repo.Worker:
return "WORKER_API_INFO" return "WORKER_API_INFO", nil, nil
default: case repo.Markets:
panic(fmt.Sprintf("Unknown repo type: %v", t)) // support split markets-miner and monolith deployments.
} return "MARKETS_API_INFO", []string{"MINER_API_INFO"}, nil
}
// TODO remove after deprecation period
func envForRepoDeprecation(t repo.RepoType) string {
switch t {
case repo.FullNode:
return "FULLNODE_API_INFO"
case repo.StorageMiner:
return "STORAGE_API_INFO"
case repo.Worker:
return "WORKER_API_INFO"
default: default:
panic(fmt.Sprintf("Unknown repo type: %v", t)) panic(fmt.Sprintf("Unknown repo type: %v", t))
} }
} }
// GetAPIInfo returns the API endpoint to use for the specified kind of repo.
//
// The order of precedence is as follows:
//
// 1. *-api-url command line flags.
// 2. *_API_INFO environment variables
// 3. deprecated *_API_INFO environment variables
// 4. *-repo command line flags.
func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) { func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) {
// Check if there was a flag passed with the listen address of the API // Check if there was a flag passed with the listen address of the API
// server (only used by the tests) // server (only used by the tests)
apiFlag := flagForAPI(t) apiFlags := flagsForAPI(t)
if ctx.IsSet(apiFlag) { for _, f := range apiFlags {
strma := ctx.String(apiFlag) if !ctx.IsSet(f) {
continue
}
strma := ctx.String(f)
strma = strings.TrimSpace(strma) strma = strings.TrimSpace(strma)
return APIInfo{Addr: strma}, nil return APIInfo{Addr: strma}, nil
} }
envKey := EnvForRepo(t) //
env, ok := os.LookupEnv(envKey) // Note: it is not correct/intuitive to prefer environment variables over
if !ok { // CLI flags (repo flags below).
// TODO remove after deprecation period //
envKey = envForRepoDeprecation(t) primaryEnv, fallbacksEnvs, deprecatedEnvs := EnvsForAPIInfos(t)
env, ok = os.LookupEnv(envKey) env, ok := os.LookupEnv(primaryEnv)
if ok {
log.Warnf("Use deprecation env(%s) value, please use env(%s) instead.", envKey, EnvForRepo(t))
}
}
if ok { if ok {
return ParseApiInfo(env), nil return ParseApiInfo(env), nil
} }
repoFlag := flagForRepo(t) for _, env := range deprecatedEnvs {
env, ok := os.LookupEnv(env)
if ok {
log.Warnf("Using deprecated env(%s) value, please use env(%s) instead.", env, primaryEnv)
return ParseApiInfo(env), nil
}
}
p, err := homedir.Expand(ctx.String(repoFlag)) repoFlags := flagsForRepo(t)
for _, f := range repoFlags {
// cannot use ctx.IsSet because it ignores default values
path := ctx.String(f)
if path == "" {
continue
}
p, err := homedir.Expand(path)
if err != nil { if err != nil {
return APIInfo{}, xerrors.Errorf("could not expand home dir (%s): %w", repoFlag, err) return APIInfo{}, xerrors.Errorf("could not expand home dir (%s): %w", f, err)
} }
r, err := repo.NewFS(p) r, err := repo.NewFS(p)
@ -133,6 +156,16 @@ func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) {
Addr: ma.String(), Addr: ma.String(),
Token: token, Token: token,
}, nil }, nil
}
for _, env := range fallbacksEnvs {
env, ok := os.LookupEnv(env)
if ok {
return ParseApiInfo(env), nil
}
}
return APIInfo{}, fmt.Errorf("could not determine API endpoint for node type: %v", t)
} }
func GetRawAPI(ctx *cli.Context, t repo.RepoType, version string) (string, http.Header, error) { func GetRawAPI(ctx *cli.Context, t repo.RepoType, version string) (string, http.Header, error) {
@ -153,10 +186,10 @@ func GetRawAPI(ctx *cli.Context, t repo.RepoType, version string) (string, http.
return addr, ainfo.AuthHeader(), nil return addr, ainfo.AuthHeader(), nil
} }
func GetAPI(ctx *cli.Context) (api.CommonNet, jsonrpc.ClientCloser, error) { func GetCommonAPI(ctx *cli.Context) (api.CommonNet, jsonrpc.ClientCloser, error) {
ti, ok := ctx.App.Metadata["repoType"] ti, ok := ctx.App.Metadata["repoType"]
if !ok { if !ok {
log.Errorf("unknown repo type, are you sure you want to use GetAPI?") log.Errorf("unknown repo type, are you sure you want to use GetCommonAPI?")
ti = repo.FullNode ti = repo.FullNode
} }
t, ok := ti.(repo.RepoType) t, ok := ti.(repo.RepoType)
@ -274,6 +307,27 @@ func GetWorkerAPI(ctx *cli.Context) (api.Worker, jsonrpc.ClientCloser, error) {
return client.NewWorkerRPCV0(ctx.Context, addr, headers) return client.NewWorkerRPCV0(ctx.Context, addr, headers)
} }
func GetMarketsAPI(ctx *cli.Context) (api.StorageMiner, jsonrpc.ClientCloser, error) {
// to support lotus-miner cli tests.
if tn, ok := ctx.App.Metadata["testnode-storage"]; ok {
return tn.(api.StorageMiner), func() {}, nil
}
addr, headers, err := GetRawAPI(ctx, repo.Markets, "v0")
if err != nil {
return nil, nil, err
}
if IsVeryVerbose {
_, _ = fmt.Fprintln(ctx.App.Writer, "using markets API v0 endpoint:", addr)
}
// the markets node is a specialised miner's node, supporting only the
// markets API, which is a subset of the miner API. All non-markets
// operations will error out with "unsupported".
return client.NewStorageMinerRPCV0(ctx.Context, addr, headers)
}
func GetGatewayAPI(ctx *cli.Context) (api.Gateway, jsonrpc.ClientCloser, error) { func GetGatewayAPI(ctx *cli.Context) (api.Gateway, jsonrpc.ClientCloser, error) {
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v1") addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v1")
if err != nil { if err != nil {

View File

@ -50,7 +50,13 @@ var infoCmd = &cli.Command{
} }
func infoCmdAct(cctx *cli.Context) error { func infoCmdAct(cctx *cli.Context) error {
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx) minerApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()
marketsApi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -64,12 +70,19 @@ func infoCmdAct(cctx *cli.Context) error {
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
subsystems, err := nodeApi.RuntimeSubsystems(ctx) subsystems, err := minerApi.RuntimeSubsystems(ctx)
if err != nil { if err != nil {
return err return err
} }
fmt.Println("Enabled subsystems:", subsystems) fmt.Println("Enabled subsystems (from miner API):", subsystems)
subsystems, err = marketsApi.RuntimeSubsystems(ctx)
if err != nil {
return err
}
fmt.Println("Enabled subsystems (from markets API):", subsystems)
fmt.Print("Chain: ") fmt.Print("Chain: ")
@ -103,19 +116,15 @@ func infoCmdAct(cctx *cli.Context) error {
fmt.Println() fmt.Println()
if subsystems.Has(api.SubsystemSectorStorage) { err = handleMiningInfo(ctx, cctx, fullapi, minerApi)
err := handleMiningInfo(ctx, cctx, fullapi, nodeApi)
if err != nil { if err != nil {
return err return err
} }
}
if subsystems.Has(api.SubsystemMarkets) { err = handleMarketsInfo(ctx, marketsApi)
err := handleMarketsInfo(ctx, nodeApi)
if err != nil { if err != nil {
return err return err
} }
}
return nil return nil
} }
@ -377,6 +386,7 @@ func handleMarketsInfo(ctx context.Context, nodeApi api.StorageMiner) error {
return sorted[i].status > sorted[j].status return sorted[i].status > sorted[j].status
}) })
fmt.Println()
fmt.Printf("Storage Deals: %d, %s\n", total.count, types.SizeStr(types.NewInt(total.bytes))) fmt.Printf("Storage Deals: %d, %s\n", total.count, types.SizeStr(types.NewInt(total.bytes)))
tw := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0) tw := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0)

View File

@ -17,7 +17,7 @@ import (
"gopkg.in/cheggaaa/pb.v1" "gopkg.in/cheggaaa/pb.v1"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
paramfetch "github.com/filecoin-project/go-paramfetch" "github.com/filecoin-project/go-paramfetch"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
lapi "github.com/filecoin-project/lotus/api" lapi "github.com/filecoin-project/lotus/api"
@ -72,7 +72,9 @@ var restoreCmd = &cli.Command{
} }
} }
if err := restore(ctx, cctx, storageCfg, nil, func(api lapi.FullNode, maddr address.Address, peerid peer.ID, mi miner.MinerInfo) error { repoPath := cctx.String(FlagMinerRepo)
if err := restore(ctx, cctx, repoPath, storageCfg, nil, func(api lapi.FullNode, maddr address.Address, peerid peer.ID, mi miner.MinerInfo) error {
log.Info("Checking proof parameters") log.Info("Checking proof parameters")
if err := paramfetch.GetParams(ctx, build.ParametersJSON(), build.SrsJSON(), uint64(mi.SectorSize)); err != nil { if err := paramfetch.GetParams(ctx, build.ParametersJSON(), build.SrsJSON(), uint64(mi.SectorSize)); err != nil {
@ -94,7 +96,7 @@ var restoreCmd = &cli.Command{
}, },
} }
func restore(ctx context.Context, cctx *cli.Context, strConfig *stores.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi miner.MinerInfo) error) error { func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *stores.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi miner.MinerInfo) error) error {
if cctx.Args().Len() != 1 { if cctx.Args().Len() != 1 {
return xerrors.Errorf("expected 1 argument") return xerrors.Errorf("expected 1 argument")
} }
@ -142,8 +144,7 @@ func restore(ctx context.Context, cctx *cli.Context, strConfig *stores.StorageCo
log.Info("Checking if repo exists") log.Info("Checking if repo exists")
repoPath := cctx.String(FlagMinerRepo) r, err := repo.NewFS(targetPath)
r, err := repo.NewFS(repoPath)
if err != nil { if err != nil {
return err return err
} }

View File

@ -71,7 +71,12 @@ var serviceCmd = &cli.Command{
return xerrors.Errorf("--api-sector-index is required without the sector storage module enabled") return xerrors.Errorf("--api-sector-index is required without the sector storage module enabled")
} }
if err := restore(ctx, cctx, &stores.StorageConfig{}, func(cfg *config.StorageMiner) error { repoPath := cctx.String(FlagMarketsRepo)
if repoPath == "" {
return xerrors.Errorf("please provide Lotus markets repo path via flag %s", FlagMarketsRepo)
}
if err := restore(ctx, cctx, repoPath, &stores.StorageConfig{}, func(cfg *config.StorageMiner) error {
cfg.Subsystems.EnableMarkets = es.Contains(MarketsService) cfg.Subsystems.EnableMarkets = es.Contains(MarketsService)
cfg.Subsystems.EnableMining = false cfg.Subsystems.EnableMining = false
cfg.Subsystems.EnableSealing = false cfg.Subsystems.EnableSealing = false

View File

@ -22,7 +22,10 @@ import (
var log = logging.Logger("main") var log = logging.Logger("main")
const FlagMinerRepo = "miner-repo" const (
FlagMinerRepo = "miner-repo"
FlagMarketsRepo = "markets-repo"
)
// TODO remove after deprecation period // TODO remove after deprecation period
const FlagMinerRepoDeprecation = "storagerepo" const FlagMinerRepoDeprecation = "storagerepo"
@ -106,14 +109,29 @@ func main() {
Value: "~/.lotusminer", // TODO: Consider XDG_DATA_HOME Value: "~/.lotusminer", // TODO: Consider XDG_DATA_HOME
Usage: fmt.Sprintf("Specify miner repo path. flag(%s) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON", FlagMinerRepoDeprecation), Usage: fmt.Sprintf("Specify miner repo path. flag(%s) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON", FlagMinerRepoDeprecation),
}, },
&cli.StringFlag{
Name: FlagMarketsRepo,
EnvVars: []string{"LOTUS_MARKETS_PATH"},
Usage: fmt.Sprintf("Markets repo path"),
},
&cli.BoolFlag{
Name: "call-on-markets",
Usage: "(experimental; may be removed) call this command against a markets node; use only with common commands like net, auth, pprof, etc. whose target may be ambiguous",
},
cliutil.FlagVeryVerbose, cliutil.FlagVeryVerbose,
}, },
Commands: append(local, lcli.CommonCommands...), Commands: append(local, lcli.CommonCommands...),
Before: func(c *cli.Context) error {
// this command is explicitly called on markets, inform
// common commands by overriding the repoType.
if c.Bool("call-on-markets") {
c.App.Metadata["repoType"] = repo.Markets
}
return nil
},
} }
app.Setup() app.Setup()
app.Metadata["repoType"] = repo.StorageMiner app.Metadata["repoType"] = repo.StorageMiner
lcli.RunApp(app) lcli.RunApp(app)
} }

View File

@ -73,7 +73,7 @@ var storageDealSelectionShowCmd = &cli.Command{
Name: "list", Name: "list",
Usage: "List storage deal proposal selection criteria", Usage: "List storage deal proposal selection criteria",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
smapi, closer, err := lcli.GetStorageMinerAPI(cctx) smapi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -100,7 +100,7 @@ var storageDealSelectionResetCmd = &cli.Command{
Name: "reset", Name: "reset",
Usage: "Reset storage deal proposal selection criteria to default values", Usage: "Reset storage deal proposal selection criteria to default values",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
smapi, closer, err := lcli.GetStorageMinerAPI(cctx) smapi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -148,7 +148,7 @@ var storageDealSelectionRejectCmd = &cli.Command{
}, },
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
smapi, closer, err := lcli.GetStorageMinerAPI(cctx) smapi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -215,7 +215,13 @@ var setAskCmd = &cli.Command{
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
ctx := lcli.DaemonContext(cctx) ctx := lcli.DaemonContext(cctx)
api, closer, err := lcli.GetStorageMinerAPI(cctx) minerApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()
marketsApi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -252,12 +258,12 @@ var setAskCmd = &cli.Command{
return xerrors.Errorf("cannot parse max-piece-size to quantity of bytes: %w", err) return xerrors.Errorf("cannot parse max-piece-size to quantity of bytes: %w", err)
} }
maddr, err := api.ActorAddress(ctx) maddr, err := minerApi.ActorAddress(ctx)
if err != nil { if err != nil {
return err return err
} }
ssize, err := api.ActorSectorSize(ctx, maddr) ssize, err := minerApi.ActorSectorSize(ctx, maddr)
if err != nil { if err != nil {
return err return err
} }
@ -272,7 +278,7 @@ var setAskCmd = &cli.Command{
return xerrors.Errorf("max piece size (w/bit-padding) %s cannot exceed miner sector size %s", types.SizeStr(types.NewInt(uint64(max))), types.SizeStr(types.NewInt(uint64(smax)))) return xerrors.Errorf("max piece size (w/bit-padding) %s cannot exceed miner sector size %s", types.SizeStr(types.NewInt(uint64(max))), types.SizeStr(types.NewInt(uint64(smax))))
} }
return api.MarketSetAsk(ctx, types.BigInt(pri), types.BigInt(vpri), abi.ChainEpoch(qty), abi.PaddedPieceSize(min), abi.PaddedPieceSize(max)) return marketsApi.MarketSetAsk(ctx, types.BigInt(pri), types.BigInt(vpri), abi.ChainEpoch(qty), abi.PaddedPieceSize(min), abi.PaddedPieceSize(max))
}, },
} }
@ -289,7 +295,7 @@ var getAskCmd = &cli.Command{
} }
defer closer() defer closer()
smapi, closer, err := lcli.GetStorageMinerAPI(cctx) smapi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -352,7 +358,7 @@ var dealsImportDataCmd = &cli.Command{
Usage: "Manually import data for a deal", Usage: "Manually import data for a deal",
ArgsUsage: "<proposal CID> <file>", ArgsUsage: "<proposal CID> <file>",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -390,7 +396,7 @@ var dealsListCmd = &cli.Command{
}, },
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -494,7 +500,7 @@ var getBlocklistCmd = &cli.Command{
&CidBaseFlag, &CidBaseFlag,
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -524,7 +530,7 @@ var setBlocklistCmd = &cli.Command{
ArgsUsage: "[<path-of-file-containing-newline-delimited-piece-CIDs> (optional, will read from stdin if omitted)]", ArgsUsage: "[<path-of-file-containing-newline-delimited-piece-CIDs> (optional, will read from stdin if omitted)]",
Flags: []cli.Flag{}, Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -570,7 +576,7 @@ var resetBlocklistCmd = &cli.Command{
Usage: "Remove all entries from the miner's piece CID blocklist", Usage: "Remove all entries from the miner's piece CID blocklist",
Flags: []cli.Flag{}, Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -634,7 +640,7 @@ var marketRestartTransfer = &cli.Command{
if !cctx.Args().Present() { if !cctx.Args().Present() {
return cli.ShowCommandHelp(cctx, cctx.Command.Name) return cli.ShowCommandHelp(cctx, cctx.Command.Name)
} }
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx) nodeApi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -699,7 +705,7 @@ var marketCancelTransfer = &cli.Command{
if !cctx.Args().Present() { if !cctx.Args().Present() {
return cli.ShowCommandHelp(cctx, cctx.Command.Name) return cli.ShowCommandHelp(cctx, cctx.Command.Name)
} }
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx) nodeApi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -775,7 +781,7 @@ var transfersListCmd = &cli.Command{
color.NoColor = !cctx.Bool("color") color.NoColor = !cctx.Bool("color")
} }
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -842,7 +848,7 @@ var dealsPendingPublish = &cli.Command{
}, },
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }

View File

@ -39,7 +39,7 @@ var retrievalDealSelectionShowCmd = &cli.Command{
Name: "list", Name: "list",
Usage: "List retrieval deal proposal selection criteria", Usage: "List retrieval deal proposal selection criteria",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
smapi, closer, err := lcli.GetStorageMinerAPI(cctx) smapi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -66,7 +66,7 @@ var retrievalDealSelectionResetCmd = &cli.Command{
Name: "reset", Name: "reset",
Usage: "Reset retrieval deal proposal selection criteria to default values", Usage: "Reset retrieval deal proposal selection criteria to default values",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
smapi, closer, err := lcli.GetStorageMinerAPI(cctx) smapi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -98,7 +98,7 @@ var retrievalDealSelectionRejectCmd = &cli.Command{
}, },
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
smapi, closer, err := lcli.GetStorageMinerAPI(cctx) smapi, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -126,7 +126,7 @@ var retrievalDealsListCmd = &cli.Command{
Name: "list", Name: "list",
Usage: "List all active retrieval deals for this miner", Usage: "List all active retrieval deals for this miner",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -186,7 +186,7 @@ var retrievalSetAskCmd = &cli.Command{
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
ctx := lcli.DaemonContext(cctx) ctx := lcli.DaemonContext(cctx)
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -240,7 +240,7 @@ var retrievalGetAskCmd = &cli.Command{
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
ctx := lcli.DaemonContext(cctx) ctx := lcli.DaemonContext(cctx)
api, closer, err := lcli.GetStorageMinerAPI(cctx) api, closer, err := lcli.GetMarketsAPI(cctx)
if err != nil { if err != nil {
return err return err
} }
@ -252,13 +252,13 @@ var retrievalGetAskCmd = &cli.Command{
} }
w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0) w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
fmt.Fprintf(w, "Price per Byte\tUnseal Price\tPayment Interval\tPayment Interval Increase\n") _, _ = fmt.Fprintf(w, "Price per Byte\tUnseal Price\tPayment Interval\tPayment Interval Increase\n")
if ask == nil { if ask == nil {
fmt.Fprintf(w, "<miner does not have an retrieval ask set>\n") _, _ = fmt.Fprintf(w, "<miner does not have an retrieval ask set>\n")
return w.Flush() return w.Flush()
} }
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n",
types.FIL(ask.PricePerByte), types.FIL(ask.PricePerByte),
types.FIL(ask.UnsealPrice), types.FIL(ask.UnsealPrice),
units.BytesSize(float64(ask.PaymentInterval)), units.BytesSize(float64(ask.PaymentInterval)),

View File

@ -43,6 +43,8 @@ GLOBAL OPTIONS:
--actor value, -a value specify other actor to check state for (read only) --actor value, -a value specify other actor to check state for (read only)
--color use color in display output (default: depends on output being a TTY) --color use color in display output (default: depends on output being a TTY)
--miner-repo value, --storagerepo value Specify miner repo path. flag(storagerepo) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON (default: "~/.lotusminer") [$LOTUS_MINER_PATH, $LOTUS_STORAGE_PATH] --miner-repo value, --storagerepo value Specify miner repo path. flag(storagerepo) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON (default: "~/.lotusminer") [$LOTUS_MINER_PATH, $LOTUS_STORAGE_PATH]
--markets-repo value Markets repo path [$LOTUS_MARKETS_PATH]
--call-on-markets (experimental; may be removed) call this command against a markets node; use only with common commands like net, auth, pprof, etc. whose target may be ambiguous (default: false)
--vv enables very verbose mode, useful for debugging the CLI (default: false) --vv enables very verbose mode, useful for debugging the CLI (default: false)
--help, -h show help (default: false) --help, -h show help (default: false)
--version, -v print the version (default: false) --version, -v print the version (default: false)

View File

@ -49,13 +49,31 @@ const (
StorageMiner StorageMiner
Worker Worker
Wallet Wallet
Markets
) )
func (t RepoType) String() string {
s := [...]string{
"__invalid__",
"FullNode",
"StorageMiner",
"Worker",
"Wallet",
"Markets",
}
if t < 0 || int(t) > len(s) {
return "__invalid__"
}
return s[t]
}
func defConfForType(t RepoType) interface{} { func defConfForType(t RepoType) interface{} {
switch t { switch t {
case FullNode: case FullNode:
return config.DefaultFullNode() return config.DefaultFullNode()
case StorageMiner: case StorageMiner, Markets:
// markets is a specialised miner service
// this taxonomy needs to be cleaned up
return config.DefaultStorageMiner() return config.DefaultStorageMiner()
case Worker: case Worker:
return &struct{}{} return &struct{}{}