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"]
|
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,6 +128,7 @@ var AuthApiInfoToken = &cli.Command{
|
|||||||
|
|
||||||
// TODO: Log in audit log when it is implemented
|
// TODO: Log in audit log when it is implemented
|
||||||
|
|
||||||
|
// WARN: this is unable to tell
|
||||||
currentEnv, _ := cliutil.EnvsForRepo(t)
|
currentEnv, _ := cliutil.EnvsForRepo(t)
|
||||||
fmt.Printf("%s=%s:%s\n", currentEnv, string(token), ainfo.Addr)
|
fmt.Printf("%s=%s:%s\n", currentEnv, string(token), ainfo.Addr)
|
||||||
return nil
|
return nil
|
||||||
|
@ -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{
|
||||||
|
@ -175,10 +175,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)
|
||||||
@ -296,6 +296,22 @@ 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) {
|
||||||
|
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 {
|
||||||
|
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")
|
var log = logging.Logger("main")
|
||||||
|
|
||||||
const (
|
const FlagMinerRepo = "miner-repo"
|
||||||
FlagMinerRepo = "miner-repo"
|
|
||||||
FlagMarketsRepo = "markets-repo"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TODO remove after deprecation period
|
// TODO remove after deprecation period
|
||||||
const FlagMinerRepoDeprecation = "storagerepo"
|
const FlagMinerRepoDeprecation = "storagerepo"
|
||||||
@ -82,7 +79,7 @@ func main() {
|
|||||||
Name: "lotus-miner",
|
Name: "lotus-miner",
|
||||||
Usage: "Filecoin decentralized storage network miner",
|
Usage: "Filecoin decentralized storage network miner",
|
||||||
Version: build.UserVersion(),
|
Version: build.UserVersion(),
|
||||||
EnableBashCompletion: true,
|
Commands: append(local, lcli.CommonCommands...),
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "actor",
|
Name: "actor",
|
||||||
@ -109,18 +106,13 @@ 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{
|
&cli.BoolFlag{
|
||||||
Name: "call-on-markets",
|
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",
|
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...),
|
EnableBashCompletion: true,
|
||||||
Before: func(c *cli.Context) error {
|
Before: func(c *cli.Context) error {
|
||||||
// this command is explicitly called on markets, inform
|
// this command is explicitly called on markets, inform
|
||||||
// common commands by overriding the repoType.
|
// common commands by overriding the repoType.
|
||||||
|
Loading…
Reference in New Issue
Block a user