Skip to content

The unfairly fast embedded nostr database backed by lmdb

License

Notifications You must be signed in to change notification settings

damus-io/nostrdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c443626 · Apr 9, 2025
Dec 16, 2023
Nov 23, 2024
Nov 23, 2024
Jul 25, 2023
Oct 8, 2023
Apr 9, 2025
Mar 20, 2025
Apr 20, 2024
Mar 20, 2025
Jul 25, 2023
Sep 13, 2023
Jul 25, 2023
May 28, 2024
Aug 27, 2024
Mar 21, 2024
Mar 20, 2025
Dec 1, 2023
Apr 9, 2025
Jan 8, 2024
Apr 9, 2025

Repository files navigation

nostrdb

ci

The unfairly fast nostr database backed by lmdb.

nostrdb stores nostr events as a custom in-memory representation that enables zero-copy and O(1) access to all note fields. This is similar to flatbuffers but it is custom built for nostr events.

These events are then memory-mapped inside lmdb, enabling insanely fast, zero-copy access and querying.

This entire design of nostrdb is copied almost entirely from strfry1, the fastest nostr relay. The difference is that nostrdb is meant to be embeddable as a C library into any application with full nostr query support.

API

The API is very unstable. nostrdb is in heavy development mode so don't expect any of the interfaces to be stable at this time.

CLI

nostrdb comes with a handy ndb command line tool for interacting with nostrdb databases. The tool is relatively new, and only supports a few commands.

Usage

usage: ndb [--skip-verification] [-d db_dir] <command>

commands

	stat
	search [--oldest-first] [--limit 42] <fulltext query>
	query [-k 42] [-k 1337] [-l 42]
	import <line-delimited json file>

settings

	--skip-verification  skip signature validation
	-d <db_dir>          set database directory

Building

$ make ndb

Fulltext Queries

nostrdb supports fulltext queries. You can import some test events like so:

$ make testdata/many-events.json
$ ndb --skip-verification import testdata/many-events.json
$ ndb search --limit 2 --oldest-first 'nosy ostrich'

[01] K<'ostrich' 7 1671217526 note_id:253309>
Q: What do you call a nosy ostrich?
A: A nosTrich!

About

The unfairly fast embedded nostr database backed by lmdb

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published