a bunch of conversions and api tweaks on khatru and eventstore.

This commit is contained in:
fiatjaf
2025-04-17 00:08:36 -03:00
parent f7884cea4f
commit a7be696243
48 changed files with 450 additions and 576 deletions

View File

@@ -24,7 +24,7 @@ type Store interface {
}
```
[![Go Reference](https://pkg.go.dev/badge/github.com/fiatjaf/eventstore.svg)](https://pkg.go.dev/github.com/fiatjaf/eventstore) [![Run Tests](https://github.com/fiatjaf/eventstore/actions/workflows/test.yml/badge.svg)](https://github.com/fiatjaf/eventstore/actions/workflows/test.yml)
[![Go Reference](https://pkg.go.dev/badge/fiatjaf.com/nostr/eventstore.svg)](https://pkg.go.dev/fiatjaf.com/nostr/eventstore) [![Run Tests](https://fiatjaf.com/nostr/eventstore/actions/workflows/test.yml/badge.svg)](https://fiatjaf.com/nostr/eventstore/actions/workflows/test.yml)
## command-line tool

View File

@@ -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

View File

@@ -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
}

View File

@@ -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)
}

View File

@@ -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)
}
}

View File

@@ -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