cli: state sector command
This commit is contained in:
parent
8a21198f56
commit
7fd5c81674
79
cli/state.go
79
cli/state.go
@ -54,6 +54,7 @@ var stateCmd = &cli.Command{
|
|||||||
stateListActorsCmd,
|
stateListActorsCmd,
|
||||||
stateListMinersCmd,
|
stateListMinersCmd,
|
||||||
stateCircSupplyCmd,
|
stateCircSupplyCmd,
|
||||||
|
stateSectorCmd,
|
||||||
stateGetActorCmd,
|
stateGetActorCmd,
|
||||||
stateLookupIDCmd,
|
stateLookupIDCmd,
|
||||||
stateReplaySetCmd,
|
stateReplaySetCmd,
|
||||||
@ -119,6 +120,13 @@ var stateMinerInfo = &cli.Command{
|
|||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
|
cd, err := api.StateMinerProvingDeadline(ctx, addr, ts.Key())
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting miner info: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Proving Period Start:\t%s\n", EpochTime(cd.CurrentEpoch, cd.PeriodStart))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -1554,6 +1562,77 @@ var stateCircSupplyCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var stateSectorCmd = &cli.Command{
|
||||||
|
Name: "sector",
|
||||||
|
Usage: "Get miner sector info",
|
||||||
|
ArgsUsage: "[miner address] [sector number]",
|
||||||
|
Action: func(cctx *cli.Context) error {
|
||||||
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer closer()
|
||||||
|
|
||||||
|
ctx := ReqContext(cctx)
|
||||||
|
|
||||||
|
if cctx.Args().Len() != 2 {
|
||||||
|
return xerrors.Errorf("expected 2 params")
|
||||||
|
}
|
||||||
|
|
||||||
|
ts, err := LoadTipSet(ctx, cctx, api)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if ts == nil {
|
||||||
|
ts, err = api.ChainHead(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
maddr, err := address.NewFromString(cctx.Args().Get(0))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
sid, err := strconv.ParseInt(cctx.Args().Get(1), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
si, err := api.StateSectorGetInfo(ctx, maddr, abi.SectorNumber(sid), ts.Key())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("SectorNumber: ", si.SectorNumber)
|
||||||
|
fmt.Println("SealProof: ", si.SealProof)
|
||||||
|
fmt.Println("SealedCID: ", si.SealedCID)
|
||||||
|
fmt.Println("DealIDs: ", si.DealIDs)
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Println("Activation: ", EpochTime(ts.Height(), si.Activation))
|
||||||
|
fmt.Println("Expiration: ", EpochTime(ts.Height(), si.Expiration))
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Println("DealWeight: ", si.DealWeight)
|
||||||
|
fmt.Println("VerifiedDealWeight: ", si.VerifiedDealWeight)
|
||||||
|
fmt.Println("InitialPledge: ", types.FIL(si.InitialPledge))
|
||||||
|
fmt.Println("ExpectedDayReward: ", types.FIL(si.ExpectedDayReward))
|
||||||
|
fmt.Println("ExpectedStoragePledge: ", types.FIL(si.ExpectedStoragePledge))
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
sp, err := api.StateSectorPartition(ctx, maddr, abi.SectorNumber(sid), ts.Key())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Deadline: ", sp.Deadline)
|
||||||
|
fmt.Println("Partition: ", sp.Partition)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
var stateMarketCmd = &cli.Command{
|
var stateMarketCmd = &cli.Command{
|
||||||
Name: "market",
|
Name: "market",
|
||||||
Usage: "Inspect the storage market actor",
|
Usage: "Inspect the storage market actor",
|
||||||
|
21
cli/util.go
21
cli/util.go
@ -2,10 +2,16 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseTipSet(ctx context.Context, api api.FullNode, vals []string) (*types.TipSet, error) {
|
func parseTipSet(ctx context.Context, api api.FullNode, vals []string) (*types.TipSet, error) {
|
||||||
@ -26,3 +32,16 @@ func parseTipSet(ctx context.Context, api api.FullNode, vals []string) (*types.T
|
|||||||
|
|
||||||
return types.NewTipSet(headers)
|
return types.NewTipSet(headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EpochTime(curr, e abi.ChainEpoch) string {
|
||||||
|
switch {
|
||||||
|
case curr > e:
|
||||||
|
return fmt.Sprintf("%d (%s ago)", e, time.Second*time.Duration(int64(build.BlockDelaySecs)*int64(curr-e)))
|
||||||
|
case curr == e:
|
||||||
|
return fmt.Sprintf("%d (now)", e)
|
||||||
|
case curr < e:
|
||||||
|
return fmt.Sprintf("%d (in %s)", e, time.Second*time.Duration(int64(build.BlockDelaySecs)*int64(e-curr)))
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("math broke")
|
||||||
|
}
|
||||||
|
@ -3,18 +3,14 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"text/tabwriter"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
"os"
|
||||||
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
)
|
)
|
||||||
@ -203,8 +199,8 @@ var provingInfoCmd = &cli.Command{
|
|||||||
fmt.Printf("Current Epoch: %d\n", cd.CurrentEpoch)
|
fmt.Printf("Current Epoch: %d\n", cd.CurrentEpoch)
|
||||||
|
|
||||||
fmt.Printf("Proving Period Boundary: %d\n", cd.PeriodStart%miner.WPoStProvingPeriod)
|
fmt.Printf("Proving Period Boundary: %d\n", cd.PeriodStart%miner.WPoStProvingPeriod)
|
||||||
fmt.Printf("Proving Period Start: %s\n", epochTime(cd.CurrentEpoch, cd.PeriodStart))
|
fmt.Printf("Proving Period Start: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.PeriodStart))
|
||||||
fmt.Printf("Next Period Start: %s\n\n", epochTime(cd.CurrentEpoch, cd.PeriodStart+miner.WPoStProvingPeriod))
|
fmt.Printf("Next Period Start: %s\n\n", lcli.EpochTime(cd.CurrentEpoch, cd.PeriodStart+miner.WPoStProvingPeriod))
|
||||||
|
|
||||||
fmt.Printf("Faults: %d (%.2f%%)\n", faults, faultPerc)
|
fmt.Printf("Faults: %d (%.2f%%)\n", faults, faultPerc)
|
||||||
fmt.Printf("Recovering: %d\n", recovering)
|
fmt.Printf("Recovering: %d\n", recovering)
|
||||||
@ -224,27 +220,14 @@ var provingInfoCmd = &cli.Command{
|
|||||||
fmt.Printf("Deadline Sectors: %d\n", curDeadlineSectors)
|
fmt.Printf("Deadline Sectors: %d\n", curDeadlineSectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Deadline Open: %s\n", epochTime(cd.CurrentEpoch, cd.Open))
|
fmt.Printf("Deadline Open: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.Open))
|
||||||
fmt.Printf("Deadline Close: %s\n", epochTime(cd.CurrentEpoch, cd.Close))
|
fmt.Printf("Deadline Close: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.Close))
|
||||||
fmt.Printf("Deadline Challenge: %s\n", epochTime(cd.CurrentEpoch, cd.Challenge))
|
fmt.Printf("Deadline Challenge: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.Challenge))
|
||||||
fmt.Printf("Deadline FaultCutoff: %s\n", epochTime(cd.CurrentEpoch, cd.FaultCutoff))
|
fmt.Printf("Deadline FaultCutoff: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.FaultCutoff))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func epochTime(curr, e abi.ChainEpoch) string {
|
|
||||||
switch {
|
|
||||||
case curr > e:
|
|
||||||
return fmt.Sprintf("%d (%s ago)", e, time.Second*time.Duration(int64(build.BlockDelaySecs)*int64(curr-e)))
|
|
||||||
case curr == e:
|
|
||||||
return fmt.Sprintf("%d (now)", e)
|
|
||||||
case curr < e:
|
|
||||||
return fmt.Sprintf("%d (in %s)", e, time.Second*time.Duration(int64(build.BlockDelaySecs)*int64(e-curr)))
|
|
||||||
}
|
|
||||||
|
|
||||||
panic("math broke")
|
|
||||||
}
|
|
||||||
|
|
||||||
var provingDeadlinesCmd = &cli.Command{
|
var provingDeadlinesCmd = &cli.Command{
|
||||||
Name: "deadlines",
|
Name: "deadlines",
|
||||||
Usage: "View the current proving period deadlines information",
|
Usage: "View the current proving period deadlines information",
|
||||||
|
Loading…
Reference in New Issue
Block a user