a bunch of conversions and api tweaks on khatru and eventstore.
This commit is contained in:
@@ -24,7 +24,7 @@ type Store interface {
|
||||
}
|
||||
```
|
||||
|
||||
[](https://pkg.go.dev/github.com/fiatjaf/eventstore) [](https://github.com/fiatjaf/eventstore/actions/workflows/test.yml)
|
||||
[](https://pkg.go.dev/fiatjaf.com/nostr/eventstore) [](https://fiatjaf.com/nostr/eventstore/actions/workflows/test.yml)
|
||||
|
||||
## command-line tool
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# eventstore command-line tool
|
||||
|
||||
```
|
||||
go install github.com/fiatjaf/eventstore/cmd/eventstore@latest
|
||||
go install fiatjaf.com/nostr/eventstore/cmd/eventstore@latest
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"fiatjaf.com/nostr/eventstore"
|
||||
"fiatjaf.com/nostr/eventstore/mmm"
|
||||
"fiatjaf.com/nostr"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
@@ -24,9 +22,7 @@ func doMmmInit(path string) (eventstore.Store, error) {
|
||||
if err := mmmm.Init(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
il := &mmm.IndexingLayer{
|
||||
ShouldIndex: func(ctx context.Context, e *nostr.Event) bool { return false },
|
||||
}
|
||||
il := &mmm.IndexingLayer{}
|
||||
if err := mmmm.EnsureLayer(filepath.Base(path), il); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
"github.com/mailru/easyjson"
|
||||
"fiatjaf.com/nostr"
|
||||
"fiatjaf.com/nostr/nip77/negentropy"
|
||||
"fiatjaf.com/nostr/nip77/negentropy/storage/vector"
|
||||
"github.com/mailru/easyjson"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
var neg = &cli.Command{
|
||||
@@ -44,11 +44,7 @@ var neg = &cli.Command{
|
||||
// create negentropy object and initialize it with events
|
||||
vec := vector.New()
|
||||
neg := negentropy.New(vec, frameSizeLimit)
|
||||
ch, err := db.QueryEvents(ctx, filter)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error querying: %s\n", err)
|
||||
}
|
||||
for evt := range ch {
|
||||
for evt := range db.QueryEvents(filter) {
|
||||
vec.Insert(evt.CreatedAt, evt.ID)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/mailru/easyjson"
|
||||
"fiatjaf.com/nostr"
|
||||
"github.com/mailru/easyjson"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
@@ -25,14 +25,7 @@ var query = &cli.Command{
|
||||
continue
|
||||
}
|
||||
|
||||
ch, err := db.QueryEvents(ctx, filter)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error querying: %s\n", err)
|
||||
hasError = true
|
||||
continue
|
||||
}
|
||||
|
||||
for evt := range ch {
|
||||
for evt := range db.QueryEvents(filter) {
|
||||
fmt.Println(evt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
"github.com/mailru/easyjson"
|
||||
"fiatjaf.com/nostr"
|
||||
"github.com/mailru/easyjson"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
var save = &cli.Command{
|
||||
@@ -25,7 +25,7 @@ var save = &cli.Command{
|
||||
continue
|
||||
}
|
||||
|
||||
if err := db.SaveEvent(ctx, &event); err != nil {
|
||||
if err := db.SaveEvent(event); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to save event '%s': %s\n", line, err)
|
||||
hasError = true
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user