Merge pull request #2252 from filecoin-project/override-maddr

add `actor` flag to `lotus-storage-miner` for proving and info calls
This commit is contained in:
Łukasz Magiera 2020-07-08 21:28:29 +02:00 committed by GitHub
commit 24d8a84ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 7 deletions

View File

@ -44,7 +44,7 @@ var infoCmd = &cli.Command{
ctx := lcli.ReqContext(cctx)
maddr, err := nodeApi.ActorAddress(ctx)
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
if err != nil {
return err
}

View File

@ -1,12 +1,16 @@
package main
import (
"context"
"os"
logging "github.com/ipfs/go-log/v2"
"github.com/urfave/cli/v2"
"go.opencensus.io/trace"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/lib/lotuslog"
@ -62,6 +66,12 @@ func main() {
Version: build.UserVersion(),
EnableBashCompletion: true,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "actor",
Value: "",
Usage: "specify other actor to check state for (read only)",
Aliases: []string{"a"},
},
&cli.StringFlag{
Name: "repo",
EnvVars: []string{"LOTUS_PATH"},
@ -85,3 +95,19 @@ func main() {
os.Exit(1)
}
}
func getActorAddress(ctx context.Context, nodeAPI api.StorageMiner, overrideMaddr string) (maddr address.Address, err error) {
if overrideMaddr != "" {
maddr, err = address.NewFromString(overrideMaddr)
if err != nil {
return maddr, err
}
}
maddr, err = nodeAPI.ActorAddress(ctx)
if err != nil {
return maddr, xerrors.Errorf("getting actor address: %w", err)
}
return maddr, nil
}

View File

@ -48,9 +48,9 @@ var provingFaultsCmd = &cli.Command{
ctx := lcli.ReqContext(cctx)
maddr, err := nodeApi.ActorAddress(ctx)
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
if err != nil {
return xerrors.Errorf("getting actor address: %w", err)
return err
}
var mas miner.State
@ -117,9 +117,9 @@ var provingInfoCmd = &cli.Command{
ctx := lcli.ReqContext(cctx)
maddr, err := nodeApi.ActorAddress(ctx)
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
if err != nil {
return xerrors.Errorf("getting actor address: %w", err)
return err
}
head, err := api.ChainHead(ctx)
@ -243,9 +243,9 @@ var provingDeadlinesCmd = &cli.Command{
ctx := lcli.ReqContext(cctx)
maddr, err := nodeApi.ActorAddress(ctx)
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
if err != nil {
return xerrors.Errorf("getting actor address: %w", err)
return err
}
deadlines, err := api.StateMinerDeadlines(ctx, maddr, types.EmptyTSK)