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:
commit
24d8a84ad7
@ -44,7 +44,7 @@ var infoCmd = &cli.Command{
|
|||||||
|
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
maddr, err := nodeApi.ActorAddress(ctx)
|
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"go.opencensus.io/trace"
|
"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"
|
"github.com/filecoin-project/lotus/build"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||||
@ -62,6 +66,12 @@ func main() {
|
|||||||
Version: build.UserVersion(),
|
Version: build.UserVersion(),
|
||||||
EnableBashCompletion: true,
|
EnableBashCompletion: true,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "actor",
|
||||||
|
Value: "",
|
||||||
|
Usage: "specify other actor to check state for (read only)",
|
||||||
|
Aliases: []string{"a"},
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "repo",
|
Name: "repo",
|
||||||
EnvVars: []string{"LOTUS_PATH"},
|
EnvVars: []string{"LOTUS_PATH"},
|
||||||
@ -85,3 +95,19 @@ func main() {
|
|||||||
os.Exit(1)
|
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
|
||||||
|
}
|
||||||
|
@ -48,9 +48,9 @@ var provingFaultsCmd = &cli.Command{
|
|||||||
|
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
maddr, err := nodeApi.ActorAddress(ctx)
|
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting actor address: %w", err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var mas miner.State
|
var mas miner.State
|
||||||
@ -117,9 +117,9 @@ var provingInfoCmd = &cli.Command{
|
|||||||
|
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
maddr, err := nodeApi.ActorAddress(ctx)
|
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting actor address: %w", err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
head, err := api.ChainHead(ctx)
|
head, err := api.ChainHead(ctx)
|
||||||
@ -243,9 +243,9 @@ var provingDeadlinesCmd = &cli.Command{
|
|||||||
|
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
maddr, err := nodeApi.ActorAddress(ctx)
|
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting actor address: %w", err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
deadlines, err := api.StateMinerDeadlines(ctx, maddr, types.EmptyTSK)
|
deadlines, err := api.StateMinerDeadlines(ctx, maddr, types.EmptyTSK)
|
||||||
|
Loading…
Reference in New Issue
Block a user