get rid of badger everywhere, including as an sdk/hints backend.
This commit is contained in:
@@ -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{
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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})
|
||||
// ...
|
||||
|
||||
@@ -31,10 +31,10 @@ relay.Info.Description = "this is my custom relay"
|
||||
relay.Info.Icon = "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fliquipedia.net%2Fcommons%2Fimages%2F3%2F35%2FSCProbe.jpg&f=1&nofb=1&ipt=0cbbfef25bce41da63d910e86c3c343e6c3b9d63194ca9755351bb7c2efa3359&ipo=images"
|
||||
```
|
||||
|
||||
Now we must set up the basic functions for accepting events and answering queries. We could make our own querying engine from scratch, but we can also use [eventstore](https://pkg.go.dev/fiatjaf.com/nostr/eventstore). In this example we'll use the Badger adapter:
|
||||
Now we must set up the basic functions for accepting events and answering queries. We could make our own querying engine from scratch, but we can also use [eventstore](https://pkg.go.dev/fiatjaf.com/nostr/eventstore). In this example we'll use the BoltDB adapter:
|
||||
|
||||
```go
|
||||
db := badger.BadgerBackend{Path: "/tmp/khatru-badger-tmp"}
|
||||
db := boltdb.BoltBackend{Path: "/tmp/khatru-bolt-tmp"}
|
||||
if err := db.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ features:
|
||||
- title: It plugs into event stores easily
|
||||
icon: 📦
|
||||
link: /core/eventstore
|
||||
details: khatru's companion, the `eventstore` library, provides all methods for storing and querying events efficiently from LMDB, Badger and others.
|
||||
details: khatru's companion, the `eventstore` library, provides all methods for storing and querying events efficiently from LMDB, BoltDB and others.
|
||||
- title: It supports NIP-42 AUTH
|
||||
icon: 🪪
|
||||
link: /core/auth
|
||||
@@ -46,7 +46,7 @@ It allows you to create a fully-functional relay in 7 lines of code:
|
||||
```go
|
||||
func main() {
|
||||
relay := khatru.NewRelay()
|
||||
db := badger.BadgerBackend{Path: "/tmp/khatru-badgern-tmp"}
|
||||
db := boltdb.BoltBackend{Path: "/tmp/khatru-bolt-tmp"}
|
||||
db.Init()
|
||||
relay.UseEventStore(db, 400)
|
||||
http.ListenAndServe(":3334", relay)
|
||||
|
||||
Reference in New Issue
Block a user