diff --git a/eventstore/cmd/eventstore/helpers.go b/eventstore/cmd/eventstore/helpers.go index 2a58b1e..f21da49 100644 --- a/eventstore/cmd/eventstore/helpers.go +++ b/eventstore/cmd/eventstore/helpers.go @@ -28,7 +28,8 @@ func detect(dir string) (string, error) { return "", err } if !f.IsDir() { - return "", fmt.Errorf("unknown db format") + // only boltdb is a file for now + return "boltdb", nil } entries, err := os.ReadDir(dir) @@ -49,14 +50,6 @@ func detect(dir string) (string, error) { } } } - // for _, entry := range entries { - // if strings.HasSuffix(entry.Name(), ".mdb") { - // return "lmdb", nil - // } - // if strings.HasSuffix(entry.Name(), ".vlog") { - // return "badger", nil - // } - // } return "", fmt.Errorf("undetected") } diff --git a/eventstore/cmd/eventstore/main.go b/eventstore/cmd/eventstore/main.go index 835e61d..a05daae 100644 --- a/eventstore/cmd/eventstore/main.go +++ b/eventstore/cmd/eventstore/main.go @@ -11,6 +11,7 @@ import ( "fiatjaf.com/nostr" "fiatjaf.com/nostr/eventstore" + "fiatjaf.com/nostr/eventstore/boltdb" "fiatjaf.com/nostr/eventstore/lmdb" "fiatjaf.com/nostr/eventstore/slicestore" "github.com/urfave/cli/v3" @@ -32,11 +33,11 @@ var app = &cli.Command{ &cli.StringFlag{ Name: "type", Aliases: []string{"t"}, - Usage: "store type ('lmdb', 'mmm')", + Usage: "store type ('lmdb', 'boltdb', 'mmm')", }, }, Before: func(ctx context.Context, c *cli.Command) (context.Context, error) { - path := strings.Trim(c.String("store"), "/") + path := strings.TrimSuffix(c.String("store"), "/") typ := c.String("type") if typ != "" { // bypass automatic detection @@ -70,6 +71,8 @@ var app = &cli.Command{ switch typ { case "lmdb": db = &lmdb.LMDBBackend{Path: path} + case "boltdb": + db = &boltdb.BoltBackend{Path: path} case "mmm": var err error if db, err = doMmmInit(path); err != nil {