get rid of badger everywhere, including as an sdk/hints backend.

This commit is contained in:
fiatjaf
2025-09-03 21:33:39 -03:00
parent a09429236e
commit cd398b94b5
16 changed files with 359 additions and 444 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ There are other `Reject*` hooks you can also implement, but this is the most imp
Blossom needs a database to keep track of blob metadata in order to know which user owns each blob, for example (and mind you that more than one user might own the same blob so when of them deletes the blob we don't actually delete it because the other user still has a claim to it). The simplest way to do it currently is by relying on a wrapper on top of fake Nostr events over eventstore, which is `EventStoreBlobIndexWrapper`, but other solutions can be used.
```go
db := &badger.BadgerBackend{Path: "/tmp/khatru-badger-blossom-blobstore"}
db := &boltdb.BoltBackend{Path: "/tmp/khatru-bolt-blossom-blobstore"}
db.Init()
bl.Store = blossom.EventStoreBlobIndexWrapper{
+3 -3
View File
@@ -14,7 +14,7 @@ The library includes many different adapters -- often called "backends" --, writ
For all of them you start by instantiating a struct containing some basic options and a pointer (a file path for local databases, a connection string for remote databases) to the data. Then you call `.Init()` and if all is well you're ready to start storing, querying and deleting events, so you can pass the respective functions to their `khatru` counterparts. These eventstores also expose a `.Close()` function that must be called if you're going to stop using that store and keep your application open.
Here's an example with the [Badger](https://pkg.go.dev/fiatjaf.com/nostr/eventstore/badger) adapter, made for the [Badger](https://github.com/dgraph-io/badger) embedded key-value database:
Here's an example with the [BoltDB](https://pkg.go.dev/fiatjaf.com/nostr/eventstore/boltdb) adapter, made for the [BoltDB](https://github.com/etcd-io/bbolt) embedded key-value database:
```go
package main
@@ -23,14 +23,14 @@ import (
"fmt"
"net/http"
"fiatjaf.com/nostr/eventstore/badger"
"fiatjaf.com/nostr/eventstore/boltdb"
"fiatjaf.com/nostr/khatru"
)
func main() {
relay := khatru.NewRelay()
db := badger.BadgerBackend{Path: "/tmp/khatru-badger-tmp"}
db := boltdb.BoltBackend{Path: "/tmp/khatru-bolt-tmp"}
if err := db.Init(); err != nil {
panic(err)
}
+1 -1
View File
@@ -12,7 +12,7 @@ It also can be handy if you get a [`khatru.Relay`](https://pkg.go.dev/github.com
sk := os.Getenv("RELAY_SECRET_KEY")
// a relay for NIP-29 groups
groupsStore := badger.BadgerBackend{}
groupsStore := boltdb.BoltBackend{}
groupsStore.Init()
groupsRelay, _ := khatru29.Init(relay29.Options{Domain: "example.com", DB: groupsStore, SecretKey: sk})
// ...