fix issues.
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
|||||||
5
errors.go
Normal file
5
errors.go
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package eventstore
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
var ErrDupEvent = errors.New("duplicate: event already exists")
|
||||||
@@ -15,9 +15,9 @@ type Storage interface {
|
|||||||
// QueryEvents is invoked upon a client's REQ as described in NIP-01.
|
// 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.
|
// 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.
|
// 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 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 is called once Relay.AcceptEvent reports true.
|
||||||
SaveEvent(ctx context.Context, event *nostr.Event) error
|
SaveEvent(context.Context, *nostr.Event) error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/fiatjaf/khatru"
|
"github.com/fiatjaf/eventstore"
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"github.com/nbd-wtf/go-nostr"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ func (b *PostgresBackend) SaveEvent(ctx context.Context, evt *nostr.Event) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if nr == 0 {
|
if nr == 0 {
|
||||||
return khatru.ErrDupEvent
|
return eventstore.ErrDupEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/fiatjaf/khatru"
|
"github.com/fiatjaf/eventstore"
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"github.com/nbd-wtf/go-nostr"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ func (b *SQLite3Backend) SaveEvent(ctx context.Context, evt *nostr.Event) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if nr == 0 {
|
if nr == 0 {
|
||||||
return storage.ErrDupEvent
|
return eventstore.ErrDupEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user