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>
This commit is contained in:
William Casarin
2023-11-26 20:04:30 -08:00
committed by Daniel D’Aquino
parent bdedf8bd8c
commit 8c5ec32eaa
3 changed files with 245 additions and 21 deletions

View File

@@ -19,8 +19,6 @@
#include "cursor.h"
#include "util.h"
#define BUFFER_SIZE 100
/*
* The prot_queue structure represents a thread-safe queue that can hold
* generic data elements.
@@ -53,7 +51,7 @@ static inline int prot_queue_init(struct prot_queue* q, void* buf,
{
// buffer elements must fit nicely in the buffer
if (buflen == 0 || buflen % elem_size != 0)
return 0;
assert(!"queue elements don't fit nicely");
q->head = 0;
q->tail = 0;