eventstore

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2024 License: CC0-1.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDupEvent = errors.New("duplicate: event already exists")

Functions

func GetAddrTagElements

func GetAddrTagElements(tagValue string) (kind uint16, pkb []byte, d string)

func TagSorter

func TagSorter(a, b tag.T) int

Types

type RelayInterface

type RelayInterface interface {
	Publish(ctx context.Context, event nip1.Event) error
	QuerySync(ctx context.Context, filter *nip1.Filter, opts ...SubscriptionOption) ([]*nip1.Event, error)
}

RelayInterface is a wrapper thing that unifies Store and nostr.Relay under a common API.

type RelayWrapper

type RelayWrapper struct {
	Store
}

func (RelayWrapper) Publish

func (w RelayWrapper) Publish(ctx context.Context, evt nip1.Event) (e error)

func (RelayWrapper) QuerySync

func (w RelayWrapper) QuerySync(ctx context.Context, filter *nip1.Filter,
	opts ...SubscriptionOption) ([]*nip1.Event, error)

type Store

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()

	// 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(context.Context, *nip1.Filter) (chan *nip1.Event, error)
	// DeleteEvent is used to handle deletion events, as per NIP-09.
	DeleteEvent(context.Context, *nip1.Event) error
	// SaveEvent is called once Relay.AcceptEvent reports true.
	SaveEvent(context.Context, *nip1.Event) error
}

Store is a persistence layer for nostr events handled by a relay.

type SubscriptionOption

type SubscriptionOption interface {
	IsSubscriptionOption()
}

SubscriptionOption is the type of the argument passed for that. Some examples are WithLabel.

type WithLabel

type WithLabel string

WithLabel puts a label on the subscription (it is prepended to the automatic id) that is sent to relays.

func (WithLabel) IsSubscriptionOption

func (_ WithLabel) IsSubscriptionOption()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL