fix issues.

This commit is contained in:
fiatjaf
2023-10-31 16:01:30 -03:00
parent e95c3cb033
commit faad1b39cd
5 changed files with 12 additions and 8 deletions

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"log"

5
errors.go Normal file
View File

@@ -0,0 +1,5 @@
package eventstore
import "errors"
var ErrDupEvent = errors.New("duplicate: event already exists")

View File

@@ -15,9 +15,9 @@ type Storage interface {
// QueryEvents is invoked upon a client's REQ as described in NIP-01.
// it should return a channel with the events as they're recovered from a database.
// the channel should be closed after the events are all delivered.
QueryEvents(ctx context.Context, filter *nostr.Filter) (chan *nostr.Event, error)
QueryEvents(context.Context, nostr.Filter) (chan *nostr.Event, error)
// DeleteEvent is used to handle deletion events, as per NIP-09.
DeleteEvent(ctx context.Context, id string, pubkey string) error
DeleteEvent(context.Context, *nostr.Event) error
// SaveEvent is called once Relay.AcceptEvent reports true.
SaveEvent(ctx context.Context, event *nostr.Event) error
SaveEvent(context.Context, *nostr.Event) error
}

View File

@@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"github.com/fiatjaf/khatru"
"github.com/fiatjaf/eventstore"
"github.com/nbd-wtf/go-nostr"
)
@@ -21,7 +21,7 @@ func (b *PostgresBackend) SaveEvent(ctx context.Context, evt *nostr.Event) error
}
if nr == 0 {
return khatru.ErrDupEvent
return eventstore.ErrDupEvent
}
return nil

View File

@@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"github.com/fiatjaf/khatru"
"github.com/fiatjaf/eventstore"
"github.com/nbd-wtf/go-nostr"
)
@@ -25,7 +25,7 @@ func (b *SQLite3Backend) SaveEvent(ctx context.Context, evt *nostr.Event) error
}
if nr == 0 {
return storage.ErrDupEvent
return eventstore.ErrDupEvent
}
return nil