allow specification of repo directory in lotus-bench

This commit is contained in:
whyrusleeping 2020-09-15 11:55:54 -07:00
parent 86607452d7
commit 24756ac056

View File

@ -56,6 +56,10 @@ var importBenchCmd = &cli.Command{
Usage: "set the parallelism factor for batch seal verification",
Value: runtime.NumCPU(),
},
&cli.StringFlag{
Name: "repodir",
Usage: "set the repo directory for the lotus bench run (defaults to /tmp)",
},
},
Action: func(cctx *cli.Context) error {
vm.BatchSealVerifyParallelism = cctx.Int("batch-seal-verify-threads")
@ -70,9 +74,15 @@ var importBenchCmd = &cli.Command{
}
defer cfi.Close() //nolint:errcheck // read only file
tdir, err := ioutil.TempDir("", "lotus-import-bench")
if err != nil {
return err
var tdir string
if rdir := cctx.String("repodir"); rdir != "" {
tdir = rdir
} else {
tmp, err := ioutil.TempDir("", "lotus-import-bench")
if err != nil {
return err
}
tdir = tmp
}
bds, err := badger.NewDatastore(tdir, nil)