store

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Unlicense Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDupEvent       = errors.New("duplicate: event already exists")
	ErrEventNotExists = errors.New("unknown: event not known by any source of this realy")
)

Functions

func GetAddrTagElements

func GetAddrTagElements(tagValue S) (k uint16, pkb B, d S)

func Less added in v1.0.4

func Less(a, b tag.T) bool

func TagSorter

func TagSorter(a, b tag.T) int

Types

type B

type B = []byte

type Ctx

type Ctx = context.T

type E

type E = error

type I

type I interface {
	// Init is called at the very beginning by [Server.Start], after [Relay.Init],
	// allowing a storage to initialize its internal resources. The parameters can be
	// used by the database implementations to set custom parameters such as cache
	// management and other relevant parameters to the specific implementation.
	Init(path S) (err E)
	// Path returns the directory of the database.
	Path() (s S)
	// Close must be called after you're done using the store, to free up resources
	// and so on.
	Close() (err E)
	// Nuke deletes everything in the database.
	Nuke() (err E)
	// QueryEvents is invoked upon a client's REQ as described in NIP-01. It returns
	// the matching events in reverse chronological order in a slice.
	QueryEvents(c Ctx, f *filter.T) (evs event.Ts, err E)
	// CountEvents performs the same work as QueryEvents but instead of delivering
	// the events that were found it just returns the count of events
	CountEvents(c Ctx, f *filter.T) (count N, approx bool, err E)
	// DeleteEvent is used to handle deletion events, as per NIP-09.
	DeleteEvent(c Ctx, ev *eventid.T) (err E)
	// SaveEvent is called once Relay.AcceptEvent reports true.
	SaveEvent(c Ctx, ev *event.T) (err E)
	// Import reads in a stream of line structured JSON of events to save into the
	// store.
	Import(r io.Reader)
	// Export writes a stream of line structured JSON of all events in the store. If
	// pubkeys are present, only those with these pubkeys in the `pubkey` field and
	// in `p` tags will be included.
	Export(c Ctx, w io.Writer, pubkeys ...B)
	// Sync signals the event store to flush its buffers.
	Sync() (err E)
}

I is an types for a persistence layer for nostr events handled by a relay.

type N

type N = int

type OK

type OK = okenvelope.T

type Req

type Req = *http.Request

type Responder

type Responder = http.ResponseWriter

type S

type S = string

type SubID

type SubID = subscription.Id

type WS

type WS = *ws.Serv

Jump to

Keyboard shortcuts

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