nostrdb: relay: add note relay iteration

This is a simple cursor that walks the NDB_DB_NOTE_RELAYS db

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-03-20 13:37:23 -07:00
committed by Daniel D’Aquino
parent 684701931d
commit a877a19c25
2 changed files with 63 additions and 0 deletions

View File

@@ -229,6 +229,13 @@ struct ndb_builder {
struct ndb_tag *current_tag;
};
struct ndb_note_relay_iterator {
struct ndb_txn *txn;
uint64_t note_key;
int cursor_op;
void *mdb_cur;
};
struct ndb_iterator {
struct ndb_note *note;
struct ndb_tag *tag;
@@ -615,6 +622,11 @@ int ndb_tags_iterate_next(struct ndb_iterator *iter);
struct ndb_str ndb_iter_tag_str(struct ndb_iterator *iter, int ind);
struct ndb_str ndb_tag_str(struct ndb_note *note, struct ndb_tag *tag, int ind);
// RELAY ITER
int ndb_note_relay_iterate_start(struct ndb_txn *txn, struct ndb_note_relay_iterator *iter, uint64_t note_key);
const char *ndb_note_relay_iterate_next(struct ndb_note_relay_iterator *iter);
void ndb_note_relay_iterate_close(struct ndb_note_relay_iterator *iter);
// NAMES
const char *ndb_db_name(enum ndb_dbs db);
const char *ndb_kind_name(enum ndb_common_kind ck);