Merge pull request #749 from filcloud/fix/make-db-config
make chainwatch db source config
This commit is contained in:
commit
318f5ad76e
@ -14,7 +14,7 @@ var dotCmd = &cli.Command{
|
|||||||
Usage: "generate dot graphs",
|
Usage: "generate dot graphs",
|
||||||
ArgsUsage: "<minHeight> <toseeHeight>",
|
ArgsUsage: "<minHeight> <toseeHeight>",
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
st, err := openStorage()
|
st, err := openStorage(cctx.String("db"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,11 @@ func main() {
|
|||||||
EnvVars: []string{"LOTUS_PATH"},
|
EnvVars: []string{"LOTUS_PATH"},
|
||||||
Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME
|
Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "db",
|
||||||
|
EnvVars: []string{"LOTUS_DB"},
|
||||||
|
Value: "./chainwatch.db",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
Commands: local,
|
Commands: local,
|
||||||
@ -70,7 +75,7 @@ var runCmd = &cli.Command{
|
|||||||
|
|
||||||
log.Info("Remote version: %s", v.Version)
|
log.Info("Remote version: %s", v.Version)
|
||||||
|
|
||||||
st, err := openStorage()
|
st, err := openStorage(cctx.String("db"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ type storage struct {
|
|||||||
headerLk sync.Mutex
|
headerLk sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func openStorage() (*storage, error) {
|
func openStorage(dbSource string) (*storage, error) {
|
||||||
db, err := sql.Open("sqlite3", "./chainwatch.db")
|
db, err := sql.Open("sqlite3", dbSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user