diff --git a/cmd/lotus-sim/main.go b/cmd/lotus-sim/main.go index dfd7c92cd..8fe313355 100644 --- a/cmd/lotus-sim/main.go +++ b/cmd/lotus-sim/main.go @@ -16,6 +16,7 @@ var root []*cli.Command = []*cli.Command{ deleteSimCommand, listSimCommand, runSimCommand, + infoSimCommand, upgradeCommand, } diff --git a/cmd/lotus-sim/simulation/simulation.go b/cmd/lotus-sim/simulation/simulation.go index 8fffd9868..384cc79cb 100644 --- a/cmd/lotus-sim/simulation/simulation.go +++ b/cmd/lotus-sim/simulation/simulation.go @@ -143,6 +143,10 @@ func (sim *Simulation) GetHead() *types.TipSet { return sim.head } +func (sim *Simulation) GetNetworkVersion() network.Version { + return sim.sm.GetNtwkVersion(context.TODO(), sim.head.Height()) +} + func (sim *Simulation) SetHead(head *types.TipSet) error { if err := sim.MetadataDS.Put(sim.key("head"), head.Key().Bytes()); err != nil { return xerrors.Errorf("failed to store simulation head: %w", err) diff --git a/cmd/lotus-sim/stat.go b/cmd/lotus-sim/stat.go new file mode 100644 index 000000000..25f9f5d51 --- /dev/null +++ b/cmd/lotus-sim/stat.go @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "text/tabwriter" + + "github.com/urfave/cli/v2" +) + +var infoSimCommand = &cli.Command{ + Name: "info", + Description: "Output information about the simulation.", + Action: func(cctx *cli.Context) error { + node, err := open(cctx) + if err != nil { + return err + } + defer node.Close() + + sim, err := node.LoadSim(cctx.Context, cctx.String("simulation")) + if err != nil { + return err + } + tw := tabwriter.NewWriter(cctx.App.Writer, 8, 8, 0, ' ', 0) + fmt.Fprintln(tw, "Name:\t", sim.Name()) + fmt.Fprintln(tw, "Height:\t", sim.GetHead().Height()) + fmt.Fprintln(tw, "TipSet:\t", sim.GetHead()) + fmt.Fprintln(tw, "Network Version:\t", sim.GetNetworkVersion()) + return tw.Flush() + }, +}