feat(lotus-sim): add an info command
This commit is contained in:
parent
be9e30e39d
commit
b7bfc06ebe
@ -16,6 +16,7 @@ var root []*cli.Command = []*cli.Command{
|
||||
deleteSimCommand,
|
||||
listSimCommand,
|
||||
runSimCommand,
|
||||
infoSimCommand,
|
||||
upgradeCommand,
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
31
cmd/lotus-sim/stat.go
Normal file
31
cmd/lotus-sim/stat.go
Normal file
@ -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()
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user