William Casarin and Daniel D’Aquino
2b14acd62f
nostrdb/filter: don't allow adding id elements on kinds
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:59 -07:00
William Casarin and Daniel D’Aquino
267a9ac54b
nostrdb/ocd: small cleanup
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:59 -07:00
William Casarin and Daniel D’Aquino
8b03ed6175
nostrdb/filters: remove ndb_filter_group from public API
...
We can just use a list of filters instead when subscribing
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:59 -07:00
William Casarin and Daniel D’Aquino
6cd7b945ca
nostrdb/filter: use binary search for large contact list filters
...
This is much more efficient than linear scans
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:59 -07:00
William Casarin and Daniel D’Aquino
e5e6735129
nostrdb/filter: sort filter elements
...
If they are sorted we can do binary search when matching filters like
how strfry does it.
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
9c2f7a931c
nostrdb/subs: always fail when calling wait_for_notes on a subid of 0
...
this is an invalid subscription id
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
b1bbf355de
nostrdb/subs: notify on profile notes as well
...
We missed this in the original subscription code
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
d7a2064786
nostrdb/debug: add a few more debug statement
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
4d14ca8d0a
nostrdb/filters: add ndb_filter_group_init function
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
81d65cd5bf
nostrdb/subs: subs and monitor cleanup
...
We need to free these resources when we're done with them.
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
f03d8a5ac9
nostrdb/search: don't enforce sequential tokens
...
This makes it a bit more flexible, but maybe we can add quoting in the
future that re-enables this. Or maybe a search option
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
0df18ae1a4
nostrdb/test: switch reaction test to use subscriptions
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
8c5ec32eaa
nostrdb/Initial nostrdb relay subscriptions
...
This adds some initial code for the nostrdb relay subscription monitor.
When new notes are written to the database, they are checked against
active subscriptions. If any of the subscriptions are matched, the note
primary key is written to the inbox queue for that subscription.
We also add an ndb_wait_for_notes() method that simply waits for notes
to be written by the subscription monitor.
Changelog-Added: Added filter subscriptions
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
bdedf8bd8c
nostrdb/disable lmdb download
...
since we have this committed now
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
c2383060aa
nostrdb/blocks: add ndb_blocks_flags function
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
432cdb96d9
nostrdb/fix: don't write the owned flag to the DB
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
f580c7dd93
nostrdb/fix clang compile issue
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
c677233dcb
nostrdb/blocks: expose block iterator internals
...
so we don't need heap allocation. we will be calling this a lot in tight
render loops, we don't want to be allocating on each frame.
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
d063362bd7
nostrdb/blocks: write note blocks on ingest
...
When ingesting notes, parse text/longform contents and store them in nostrdb.
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
088683696a
nostrdb/blocks: actually set the note block version
...
Version 1 to start
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
f2795aa71c
nostrdb/blocks: add ndb_blocks_free
...
In some situations we will need to have owned note blocks. For
example, when we try to fetch note blocks from the database and it's not
there yet. We will need to parse the content on the spot and return an
owned copy, since it will not be immediately available in the database.
Add a new flag field to note blocks that lets us know if it's owned by
malloc or nostrdb.
We the add a free function that checks this flag and frees the object if
its set. If it is not set then it doesn nothing because it likely came
from the database.
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
c831976078
nostrdb/blocks: add total_size
...
Fix this mistake that we have with ndb_notes where we don't know the
total size of the object
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
c2c73c3af6
nostrdb/header: move bech32 around
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
971fa3e4ef
nostrdb/invoice: fix crash in any-amount invoice parsing
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
dfa145dd4a
nostrdb/parser: fix bech32 block decoding
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
4cfe28d802
nostrdb/bech32: fix big in bech32 size parsing
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
034f2cc02f
nostrdb/blocks: add note block iterator
...
This adds an api that walks along and pulls compact note block data out of
nostrdb.
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
kernelkind and Daniel D’Aquino
6f9bd6c4f4
nostrdb/parser: handle period at end of url
...
Fix parsing URL when encountering a period at the end of the url by
setting it as disallowed from being present at the end of a
URL.
Some characters are disallowed to be present at the end of URLs.
Presently, the period character is the only disallowed character.
A character is the last character in the URL if it is followed by
is_whitespace() or if it's the last character in the string.
Signed-off-by: kernelkind <kernelkind@gmail.com >
Tested-by: William Casarin <jb55@jb55.com >
Signed-off-by: William Casarin <jb55@jb5.com >
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
d73422db38
nostrdb/content_parser: add initial db decoders
...
We need to pull the data out as well! Let's add some initial decoders.
We still need tests to make sure it's working.
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
c3b06d281e
nostrdb/bech32: add some initial tests
...
since we modified this recently, let's add some tests to make sure
we didn't break anything
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
1b09e9458c
nostrdb/nostr_bech32: parse in one pass
...
since we will be decoding these in realtime, let's make sure we can
decode them in O(1)
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
e0a2dcf3db
nostrdb/Inital embedded content parser
...
This adds some initial code for nostrdb content parsing.
We still need to write tests for encoding and decoding, so this is
likely not working yet.
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
9ff1f69a82
nostrdb/search: switch to cursor_align function
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
623b8603c2
nostrdb/cursor: add align function
...
handy function for padding buffers to some byte alignment
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
d8b083010d
nostrdb/cursor: fix some warnings
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
887eb4e1e2
nostrdb/cursor: fix empty string pushing in push_c_str
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
b5ad3ed1a5
nostrdb/cursor: add pull_varint_u32
...
This is a varint helper that doesn't pull larger than uint32
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
371e9fb406
nostrdb/cursor: add malloc_slice
...
This is the same as cursor_slice except we don't memset afterwards
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
aa5809d792
nostrdb/nostr_bech32: only parse up to raw bech32 buffers
...
We will be storing raw nostr bech32 buffers directly into nostrdb, so
adapt our bech32 code to reflect this.
When doing our content parsing pass, we will only look for strings and we
won't allocate any intermediate buffers. Only when we write this string
block to nostrdb will we actually allocate in our nostrdb output buffer
(no mallocs!)
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
30ba0d72cc
nostrdb/bech32: retab
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
373cd71f69
nostrdb/block: add bolt11 invoice encoding/decoding
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
acaf327a07
nostrdb/make: cleanup a bit, separate bench running
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
9f0bf7dff5
nostrdb/fix github action
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
88d7eb8a86
nostrdb/fix build
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
76862776b8
nostrdb/varint: switch to 64 bit varints
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
4c55459c1f
nostrdb/test: disable migrate for now
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
f7cdc7bc31
nostrdb/cursor: re-apply infinite loop bug fix
...
since I keep overwriting it by accident
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
1bc4971111
nostrdb/add libnostrdb.a
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
6ce6c79160
nostrdb/add initial content parser
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00
William Casarin and Daniel D’Aquino
1ffbd80c67
nostrdb: move everything to src
...
Signed-off-by: William Casarin <jb55@jb55.com >
2025-08-11 16:39:43 -07:00