eventstore

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: Unlicense Imports: 7 Imported by: 31 modules, 55 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

eventstore

A collection of reusable database connectors, wrappers and schemas that store Nostr events and expose a simple Go interface:

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, nostr.Filter) (chan *nostr.Event, error)

	// DeleteEvent is used to handle deletion events, as per NIP-09.
	DeleteEvent(context.Context, *nostr.Event) error

	// SaveEvent is called once Relay.AcceptEvent reports true.
	SaveEvent(context.Context, *nostr.Event) error
}

Go Reference Run Tests

command-line tool

There is an eventstore command-line tool that can be used to query these databases directly.

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func GetAddrTagElements added in v0.2.12

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

Types

type Counter added in v0.7.2

type Counter interface {
	CountEvents(context.Context, nostr.Filter) (int64, error)
}

type RelayWrapper

type RelayWrapper struct {
	Store
}

func (RelayWrapper) Publish

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

func (RelayWrapper) QuerySync

func (w RelayWrapper) QuerySync(ctx context.Context, filter nostr.Filter) ([]*nostr.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, nostr.Filter) (chan *nostr.Event, error)
	// DeleteEvent is used to handle deletion events, as per NIP-09.
	DeleteEvent(context.Context, *nostr.Event) error
	// SaveEvent is called once Relay.AcceptEvent reports true.
	SaveEvent(context.Context, *nostr.Event) error
}

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

Directories

Path Synopsis
cmd
eventstore command
internal
wrappers

Jump to

Keyboard shortcuts

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