nostrdb

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

commit 9a5566487ab093599d63bed3b946ef6292d619cd
parent 966b23f008faff35f31528db73e4147562782724
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 13 Dec 2024 17:22:38 -0800

add ndb_db_is_index

This function can be used to check if a db is an index or not. We
will use this in future functions that rebuild indices.

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

Diffstat:
Msrc/nostrdb.c | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/nostrdb.c b/src/nostrdb.c @@ -1409,6 +1409,31 @@ static int ndb_begin_rw_query(struct ndb *ndb, struct ndb_txn *txn) return _ndb_begin_query(ndb, txn, 0); } +static int ndb_db_is_index(enum ndb_dbs index) +{ + switch (index) { + case NDB_DB_NOTE: + case NDB_DB_META: + case NDB_DB_PROFILE: + case NDB_DB_NOTE_ID: + case NDB_DB_NDB_META: + case NDB_DB_PROFILE_SEARCH: + case NDB_DB_PROFILE_LAST_FETCH: + case NDB_DBS: + return 0; + case NDB_DB_PROFILE_PK: + case NDB_DB_NOTE_KIND: + case NDB_DB_NOTE_TEXT: + case NDB_DB_NOTE_BLOCKS: + case NDB_DB_NOTE_TAGS: + case NDB_DB_NOTE_PUBKEY: + case NDB_DB_NOTE_PUBKEY_KIND: + return 1; + } + + return 0; +} + static inline void ndb_id_u64_ts_init(struct ndb_id_u64_ts *key, unsigned char *id, uint64_t iu64, uint64_t timestamp)