nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

commit db5a509c4d134ff692bf776082a8202fa00e0081
parent 0bdaf18cac197b0f17c0da65afa68a653bbd9f04
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 21 Mar 2025 12:52:29 -0700

note: always write relay index

This fixes a race condition where if multiple of the same note
is processed at the same time, we still manage to write the
note relays

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/nostrdb.c | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/nostrdb.c b/src/nostrdb.c @@ -4665,8 +4665,14 @@ static uint64_t ndb_write_note(struct ndb_txn *txn, kind = note->note->kind; // let's quickly sanity check if we already have this note - if (ndb_get_notekey_by_id(txn, note->note->id)) + if (ndb_get_notekey_by_id(txn, note->note->id)) { + // even if we do we still need to write relay index + ndb_write_note_relay_kind_index(txn, kind, note_key, + ndb_note_created_at(note->note), + note->relay, relay_len); + ndb_write_note_relay(txn, note_key, note->relay, relay_len); return 0; + } // get dbs note_db = txn->lmdb->dbs[NDB_DB_NOTE];