lotus/cmd/lotus-sim/create.go

45 lines
912 B
Go
Raw Permalink Normal View History

2021-05-19 00:01:30 +00:00
package main
import (
"fmt"
"github.com/urfave/cli/v2"
2021-05-19 00:01:30 +00:00
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
)
var createSimCommand = &cli.Command{
Name: "create",
ArgsUsage: "[tipset]",
2021-06-18 18:17:35 +00:00
Action: func(cctx *cli.Context) (err error) {
2021-05-19 00:01:30 +00:00
node, err := open(cctx)
if err != nil {
return err
}
2021-06-18 18:17:35 +00:00
defer func() {
if cerr := node.Close(); err == nil {
err = cerr
}
}()
2021-05-19 00:01:30 +00:00
var ts *types.TipSet
switch cctx.NArg() {
case 0:
2021-12-13 13:15:38 +00:00
if err := node.Chainstore.Load(cctx.Context); err != nil {
2021-05-19 00:01:30 +00:00
return err
}
ts = node.Chainstore.GetHeaviestTipSet()
case 1:
ts, err = lcli.ParseTipSetRefOffline(cctx.Context, node.Chainstore, cctx.Args().Get(1))
2021-05-19 00:01:30 +00:00
if err != nil {
return err
}
default:
return fmt.Errorf("expected 0 or 1 arguments")
}
_, err = node.CreateSim(cctx.Context, cctx.String("simulation"), ts)
return err
},
}