eventstore

package
v0.0.0-...-f50b7b0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Unlicense Imports: 4 Imported by: 8

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 returns events that match the filter
	QueryEvents(filter nostr.Filter, maxLimit int) iter.Seq[nostr.Event]

	// DeleteEvent deletes an event atomically by ID
	DeleteEvent(nostr.ID) error

	// SaveEvent just saves an event, no side-effects.
	SaveEvent(nostr.Event) error

	// ReplaceEvent atomically replaces a replaceable or addressable event.
	// Conceptually it is like a Query->Delete->Save, but streamlined.
	ReplaceEvent(nostr.Event) error

	// CountEvents counts all events that match a given filter
	CountEvents(nostr.Filter) (uint32, error)
}

Available Implementations

  • bleve: Full-text search and indexing using the Bleve search library
  • boltdb: Embedded key-value database using BoltDB
  • lmdb: High-performance embedded database using LMDB
  • mmm: Custom memory-mapped storage with advanced indexing
  • nullstore: No-op store for testing and development
  • slicestore: Simple in-memory slice-based store

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 SortedMerge

func SortedMerge(it1, it2 iter.Seq[nostr.Event], limit int) iter.Seq[nostr.Event]

SortedMerge combines two iterators and returns the top limit results aggregated from both. limit is implied to be also the maximum number of items each iterator will return.

Types

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 returns events that match the filter
	QueryEvents(filter nostr.Filter, maxLimit int) iter.Seq[nostr.Event]

	// DeleteEvent deletes an event atomically by ID
	DeleteEvent(nostr.ID) error

	// SaveEvent just saves an event, no side-effects.
	SaveEvent(nostr.Event) error

	// ReplaceEvent atomically replaces a replaceable or addressable event.
	// Conceptually it is like a Query->Delete->Save, but streamlined.
	ReplaceEvent(nostr.Event) (deleted []nostr.Event, err error)

	// CountEvents counts all events that match a given filter
	CountEvents(nostr.Filter) (uint32, error)
}

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

Directories

Path Synopsis
cmd
eventstore command
codec

Jump to

Keyboard shortcuts

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