Add flag to accept previous output of compute-state as input
This commit is contained in:
parent
b7c8f65af5
commit
3b12a9f425
29
cli/state.go
29
cli/state.go
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
@ -32,6 +33,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/exitcode"
|
"github.com/filecoin-project/go-state-types/exitcode"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
|
lapi "github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/apibstore"
|
"github.com/filecoin-project/lotus/api/apibstore"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/state"
|
"github.com/filecoin-project/lotus/chain/state"
|
||||||
@ -823,6 +825,10 @@ var stateComputeStateCmd = &cli.Command{
|
|||||||
Name: "json",
|
Name: "json",
|
||||||
Usage: "generate json output",
|
Usage: "generate json output",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "compute-state-output",
|
||||||
|
Usage: "a json file containing pre-existing compute-state output, to generate html reports without rerunning state changes",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := GetFullNodeAPI(cctx)
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
@ -862,9 +868,26 @@ var stateComputeStateCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stout, err := api.StateCompute(ctx, h, msgs, ts.Key())
|
var stout *lapi.ComputeStateOutput
|
||||||
if err != nil {
|
if csofile := cctx.String("compute-state-output"); csofile != "" {
|
||||||
return err
|
data, err := ioutil.ReadFile(csofile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var o lapi.ComputeStateOutput
|
||||||
|
if err := json.Unmarshal(data, &o); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
stout = &o
|
||||||
|
} else {
|
||||||
|
o, err := api.StateCompute(ctx, h, msgs, ts.Key())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
stout = o
|
||||||
}
|
}
|
||||||
|
|
||||||
if cctx.Bool("json") {
|
if cctx.Bool("json") {
|
||||||
|
Loading…
Reference in New Issue
Block a user