diff --git a/cmd/lotus-chainwatch/dot.go b/cmd/lotus-chainwatch/dot.go index 83b9888f8..2a899c100 100644 --- a/cmd/lotus-chainwatch/dot.go +++ b/cmd/lotus-chainwatch/dot.go @@ -14,7 +14,7 @@ var dotCmd = &cli.Command{ Usage: "generate dot graphs", ArgsUsage: " ", Action: func(cctx *cli.Context) error { - st, err := openStorage() + st, err := openStorage(cctx.String("db")) if err != nil { return err } diff --git a/cmd/lotus-chainwatch/main.go b/cmd/lotus-chainwatch/main.go index c8ea2d863..187f2a17d 100644 --- a/cmd/lotus-chainwatch/main.go +++ b/cmd/lotus-chainwatch/main.go @@ -35,6 +35,11 @@ func main() { EnvVars: []string{"LOTUS_PATH"}, Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME }, + &cli.StringFlag{ + Name: "db", + EnvVars: []string{"LOTUS_DB"}, + Value: "./chainwatch.db", + }, }, Commands: local, @@ -70,7 +75,7 @@ var runCmd = &cli.Command{ log.Info("Remote version: %s", v.Version) - st, err := openStorage() + st, err := openStorage(cctx.String("db")) if err != nil { return err } diff --git a/cmd/lotus-chainwatch/storage.go b/cmd/lotus-chainwatch/storage.go index 572b8dde3..3f2a2bf0d 100644 --- a/cmd/lotus-chainwatch/storage.go +++ b/cmd/lotus-chainwatch/storage.go @@ -18,8 +18,8 @@ type storage struct { headerLk sync.Mutex } -func openStorage() (*storage, error) { - db, err := sql.Open("sqlite3", "./chainwatch.db") +func openStorage(dbSource string) (*storage, error) { + db, err := sql.Open("sqlite3", dbSource) if err != nil { return nil, err }