update readmes so they're less outdated.

This commit is contained in:
fiatjaf
2025-09-22 17:05:17 -03:00
parent 04e095eb1b
commit fd9f956a3d
5 changed files with 64 additions and 24 deletions

View File

@@ -1,10 +1,19 @@
nostr library # nostr
=============
supposed to contain everything you need to write a relay or client or hybrid or anything else. A comprehensive Go library for the Nostr protocol, providing everything needed to build relays, clients, or hybrid applications.
this is a fork of https://github.com/nbd-wtf/go-nostr with better types and other random changes or features. This is a fork of [go-nostr](https://github.com/nbd-wtf/go-nostr) with enhanced types, additional features, and extensive NIP support.
## Installation
```sh ```sh
go get fiatjaf.com/nostr go get fiatjaf.com/nostr
``` ```
## Components
- **eventstore**: Pluggable storage backends (Bluge, BoltDB, LMDB, in-memory, nullstore)
- **khatru**: Relay framework for building Nostr relays
- **sdk**: Client SDK with caching, data loading, and relay management
- **keyer**: Key management utilities
- **NIPs**: Implementations for NIPs 4-94, covering encryption, metadata, relays, and more

View File

@@ -11,21 +11,35 @@ type Store interface {
// Close must be called after you're done using the store, to free up resources and so on. // Close must be called after you're done using the store, to free up resources and so on.
Close() Close()
// QueryEvents is invoked upon a client's REQ as described in NIP-01. // QueryEvents returns events that match the filter
// it should return a channel with the events as they're recovered from a database. QueryEvents(filter nostr.Filter, maxLimit int) iter.Seq[nostr.Event]
// 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 deletes an event atomically by ID
DeleteEvent(context.Context, *nostr.Event) error DeleteEvent(nostr.ID) error
// SaveEvent is called once Relay.AcceptEvent reports true. // SaveEvent just saves an event, no side-effects.
SaveEvent(context.Context, *nostr.Event) error 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)
} }
``` ```
[![Go Reference](https://pkg.go.dev/badge/fiatjaf.com/nostr/eventstore.svg)](https://pkg.go.dev/fiatjaf.com/nostr/eventstore) [![Run Tests](https://fiatjaf.com/nostr/eventstore/actions/workflows/test.yml/badge.svg)](https://fiatjaf.com/nostr/eventstore/actions/workflows/test.yml) [![Go Reference](https://pkg.go.dev/badge/fiatjaf.com/nostr/eventstore.svg)](https://pkg.go.dev/fiatjaf.com/nostr/eventstore) [![Run Tests](https://fiatjaf.com/nostr/eventstore/actions/workflows/test.yml/badge.svg)](https://fiatjaf.com/nostr/eventstore/actions/workflows/test.yml)
## command-line tool ## Available Implementations
- **bluge**: Full-text search and indexing using the Bluge 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](cmd/eventstore) that can be used to query these databases directly. There is an [`eventstore` command-line tool](cmd/eventstore) that can be used to query these databases directly.

View File

@@ -26,14 +26,23 @@ This will automatically determine the storage type being used at `/path/to/store
~> echo '{"id":"35369e6bae5f77c4e1745c2eb5db84c4493e87f6e449aee62a261bbc1fea2788","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1701193836,"kind":1,"tags":[],"content":"hello","sig":"ef08d559e042d9af4cdc3328a064f737603d86ec4f929f193d5a3ce9ea22a3fb8afc1923ee3c3742fd01856065352c5632e91f633528c80e9c5711fa1266824c"}' | eventstore -d /path/to/store save ~> echo '{"id":"35369e6bae5f77c4e1745c2eb5db84c4493e87f6e449aee62a261bbc1fea2788","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1701193836,"kind":1,"tags":[],"content":"hello","sig":"ef08d559e042d9af4cdc3328a064f737603d86ec4f929f193d5a3ce9ea22a3fb8afc1923ee3c3742fd01856065352c5632e91f633528c80e9c5711fa1266824c"}' | eventstore -d /path/to/store save
``` ```
You can also create a database from scratch if it's a disk database, but then you have to specify `-t` to `boltdb` or `lmdb`. ### Counting events matching a filter
### Connecting to Postgres, MySQL and other remote databases ```fish
~> echo '{"kinds":[1]}' | eventstore -d /path/to/store count
You should be able to connect by just passing the database connection URI to `-d`:
```bash
~> eventstore -d 'postgres://myrelay:38yg4o83yf48a3s7g@localhost:5432/myrelay?sslmode=disable' <query|save|delete>
``` ```
That should be prefixed with `postgres://` for Postgres, `mysql://` for MySQL and `https://` for ElasticSearch. ### Deleting an event by ID
```fish
~> echo '35369e6bae5f77c4e1745c2eb5db84c4493e87f6e449aee62a261bbc1fea2788' | eventstore -d /path/to/store delete
```
### Query or save (default command)
Pipes events or filters and handles them appropriately.
You can also create a database from scratch if it's a disk database, but then you have to specify `-t` to `boltdb` or `lmdb`.
Supported store types: `lmdb`, `boltdb`, `mmm`, `file` (for JSONL files).

View File

@@ -1,2 +1,11 @@
`nullstore` is an eventstore that doesn't actually do anything. # NullStore
It doesn't store anything, it doesn't return anything.
`nullstore` is a no-op implementation of the eventstore interface that doesn't actually store or retrieve any events.
All operations succeed without error but have no effect:
- `SaveEvent` and `ReplaceEvent` do nothing
- `QueryEvents` returns an empty iterator
- `DeleteEvent` does nothing
- `CountEvents` returns 0
This is useful for testing, development environments, or when event persistence is not required.

View File

@@ -1 +0,0 @@
Code copied from https://github.com/paulmillr/nip44/tree/e7aed61aaf77240ac10c325683eed14b22e7950f/go.