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",
|
||||
ArgsUsage: "<minHeight> <toseeHeight>",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
st, err := openStorage()
|
||||
st, err := openStorage(cctx.String("db"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user