Merge pull request #749 from filcloud/fix/make-db-config

make chainwatch db source config
This commit is contained in:
Łukasz Magiera 2019-12-05 13:01:37 +01:00 committed by GitHub
commit 318f5ad76e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -14,7 +14,7 @@ var dotCmd = &cli.Command{
Usage: "generate dot graphs",
ArgsUsage: "<minHeight> <toseeHeight>",
Action: func(cctx *cli.Context) error {
st, err := openStorage()
st, err := openStorage(cctx.String("db"))
if err != nil {
return err
}

View File

@ -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
}

View File

@ -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
}