2024-09-17 01:01:42 +00:00
|
|
|
package eventstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/nbd-wtf/go-nostr"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Store is a persistence layer for nostr events handled by a relay.
|
|
|
|
type Store interface {
|
|
|
|
// Init is called at the very beginning by [Server.Start], after [Relay.Init],
|
|
|
|
// allowing a storage to initialize its internal resources.
|
|
|
|
Init() error
|
|
|
|
|
|
|
|
// Close must be called after you're done using the store, to free up resources and so on.
|
|
|
|
Close()
|
|
|
|
|
2024-11-11 19:56:01 +00:00
|
|
|
// QueryEvents 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.
|
2024-09-17 01:01:42 +00:00
|
|
|
QueryEvents(context.Context, nostr.Filter) (chan *nostr.Event, error)
|
2024-11-11 19:56:01 +00:00
|
|
|
// DeleteEvent just deletes an event, no side-effects.
|
2024-09-17 01:01:42 +00:00
|
|
|
DeleteEvent(context.Context, *nostr.Event) error
|
2024-11-11 19:56:01 +00:00
|
|
|
// SaveEvent just saves an event, no side-effects.
|
2024-09-17 01:01:42 +00:00
|
|
|
SaveEvent(context.Context, *nostr.Event) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type Counter interface {
|
|
|
|
CountEvents(context.Context, nostr.Filter) (int64, error)
|
|
|
|
}
|