1package tinygit23import (4 "context"56 "github.com/FelineStateMachine/tinyrelay/internal/gitstore"7 "github.com/FelineStateMachine/tinyrelay/protocol/nostr"8)910var _ Store = (*gitstore.Store)(nil)1112// Store is the persistence contract required by GitRelay. Implementations may13// use any durable or in-memory representation of Nostr events. The caller14// owns the store; New never closes it.15type Store interface {16 // Query returns matching events by descending timestamp, then ascending ID,17 // excluding expired, hidden and pending events without applying reader ACLs.18 // now is the Unix expiry cutoff. A positive limit caps the result; f.Limit19 // can impose a smaller cap. With neither limit, all matches are returned.20 Query(context.Context, nostr.Filter, int64, int) ([]Event, error)21 // Save durably records e using now for storage timestamps. Duplicate events22 // return ErrDuplicate.23 Save(context.Context, Event, int64) error24 // Latest returns the newest addressable event for kind, pubkey and d.25 // Ties use the lowest event ID. This includes expired, hidden and pending26 // rows so recovery can check durable state independently of read visibility.27 Latest(context.Context, int, string, string) (Event, bool, error)28 // Exists reports whether id is present with the requested kind.29 Exists(context.Context, string, int) (bool, error)30 // Close releases resources owned by the store.31 Close() error32}3334// ErrDuplicate indicates that an event was already persisted.35var ErrDuplicate = gitstore.ErrDuplicate3637// OpenStore opens the standard SQLite event schema behind the public Store38// contract. The caller owns the returned store and must close it.39func OpenStore(ctx context.Context, path string) (Store, error) { return gitstore.Open(ctx, path) }