diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 4e54252bc..99c09dde2 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -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 } diff --git a/cmd/lotus-storage-miner/main.go b/cmd/lotus-storage-miner/main.go index 62efe9370..ae8ea79e7 100644 --- a/cmd/lotus-storage-miner/main.go +++ b/cmd/lotus-storage-miner/main.go @@ -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 +} diff --git a/cmd/lotus-storage-miner/proving.go b/cmd/lotus-storage-miner/proving.go index 791f3a88a..6420fbe5e 100644 --- a/cmd/lotus-storage-miner/proving.go +++ b/cmd/lotus-storage-miner/proving.go @@ -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)