target markets API for markets commands.
This commit is contained in:
parent
22461f30e9
commit
a1aed960a9
@ -113,7 +113,7 @@ var AuthApiInfoToken = &cli.Command{
|
||||
|
||||
ti, ok := cctx.App.Metadata["repoType"]
|
||||
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
|
||||
}
|
||||
t, ok := ti.(repo.RepoType)
|
||||
@ -128,6 +128,7 @@ var AuthApiInfoToken = &cli.Command{
|
||||
|
||||
// TODO: Log in audit log when it is implemented
|
||||
|
||||
// WARN: this is unable to tell
|
||||
currentEnv, _ := cliutil.EnvsForRepo(t)
|
||||
fmt.Printf("%s=%s:%s\n", currentEnv, string(token), ainfo.Addr)
|
||||
return nil
|
||||
|
@ -44,7 +44,7 @@ func GetFullNodeServices(ctx *cli.Context) (ServicesAPI, error) {
|
||||
|
||||
var GetAPIInfo = cliutil.GetAPIInfo
|
||||
var GetRawAPI = cliutil.GetRawAPI
|
||||
var GetAPI = cliutil.GetAPI
|
||||
var GetAPI = cliutil.GetCommonAPI
|
||||
|
||||
var DaemonContext = cliutil.DaemonContext
|
||||
var ReqContext = cliutil.ReqContext
|
||||
@ -54,6 +54,7 @@ var GetFullNodeAPIV1 = cliutil.GetFullNodeAPIV1
|
||||
var GetGatewayAPI = cliutil.GetGatewayAPI
|
||||
|
||||
var GetStorageMinerAPI = cliutil.GetStorageMinerAPI
|
||||
var GetMarketsAPI = cliutil.GetMarketsAPI
|
||||
var GetWorkerAPI = cliutil.GetWorkerAPI
|
||||
|
||||
var CommonCommands = []*cli.Command{
|
||||
|
@ -175,10 +175,10 @@ func GetRawAPI(ctx *cli.Context, t repo.RepoType, version string) (string, http.
|
||||
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"]
|
||||
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
|
||||
}
|
||||
t, ok := ti.(repo.RepoType)
|
||||
@ -296,6 +296,22 @@ func GetWorkerAPI(ctx *cli.Context) (api.Worker, jsonrpc.ClientCloser, error) {
|
||||
return client.NewWorkerRPCV0(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
func GetMarketsAPI(ctx *cli.Context) (api.StorageMiner, jsonrpc.ClientCloser, error) {
|
||||
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) {
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v1")
|
||||
if err != nil {
|
||||
|
30
cmd/lotus-miner/dagstore.go
Normal file
30
cmd/lotus-miner/dagstore.go
Normal file
@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var dagstoreCmd = &cli.Command{
|
||||
Name: "dagstore",
|
||||
Usage: "Manage the DAG store",
|
||||
Subcommands: []*cli.Command{
|
||||
dagstoreListShardsCmd,
|
||||
dagstoreGarbageCollectCmd,
|
||||
},
|
||||
}
|
||||
|
||||
var dagstoreListShardsCmd = &cli.Command{
|
||||
Name: "list-shards",
|
||||
Usage: "List shards known to the DAG store",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var dagstoreGarbageCollectCmd = &cli.Command{
|
||||
Name: "gc",
|
||||
Usage: "Garbage collect the DAG store",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
return nil
|
||||
},
|
||||
}
|
@ -22,10 +22,7 @@ import (
|
||||
|
||||
var log = logging.Logger("main")
|
||||
|
||||
const (
|
||||
FlagMinerRepo = "miner-repo"
|
||||
FlagMarketsRepo = "markets-repo"
|
||||
)
|
||||
const FlagMinerRepo = "miner-repo"
|
||||
|
||||
// TODO remove after deprecation period
|
||||
const FlagMinerRepoDeprecation = "storagerepo"
|
||||
@ -79,10 +76,10 @@ func main() {
|
||||
}
|
||||
|
||||
app := &cli.App{
|
||||
Name: "lotus-miner",
|
||||
Usage: "Filecoin decentralized storage network miner",
|
||||
Version: build.UserVersion(),
|
||||
EnableBashCompletion: true,
|
||||
Name: "lotus-miner",
|
||||
Usage: "Filecoin decentralized storage network miner",
|
||||
Version: build.UserVersion(),
|
||||
Commands: append(local, lcli.CommonCommands...),
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "actor",
|
||||
@ -109,18 +106,13 @@ func main() {
|
||||
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),
|
||||
},
|
||||
&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,
|
||||
},
|
||||
Commands: append(local, lcli.CommonCommands...),
|
||||
EnableBashCompletion: true,
|
||||
Before: func(c *cli.Context) error {
|
||||
// this command is explicitly called on markets, inform
|
||||
// common commands by overriding the repoType.
|
||||
|
Loading…
Reference in New Issue
Block a user