nostrdb

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

commit 25494ff7712d6caa74b4a8cdf14b86cd83773d31
parent 11e61383f70d5870a7fd991a3f1de9df2f282d55
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 13 Dec 2024 17:21:20 -0800

misc: move some functions around

because this will make the changes nicer

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

Diffstat:
Msrc/nostrdb.c | 53++++++++++++++++++++++++++---------------------------
1 file changed, 26 insertions(+), 27 deletions(-)

diff --git a/src/nostrdb.c b/src/nostrdb.c @@ -1355,6 +1355,32 @@ static int ndb_write_profile_search_indices(struct ndb_txn *txn, return 1; } +static inline void ndb_tsid_init(struct ndb_tsid *key, unsigned char *id, + uint64_t timestamp) +{ + memcpy(key->id, id, 32); + key->timestamp = timestamp; +} + +static inline void ndb_tsid_low(struct ndb_tsid *key, unsigned char *id) +{ + memcpy(key->id, id, 32); + key->timestamp = 0; +} + +static inline void ndb_u64_ts_init(struct ndb_u64_ts *key, uint64_t integer, + uint64_t timestamp) +{ + key->u64 = integer; + key->timestamp = timestamp; +} + +// useful for range-searching for the latest key with a clustered created_at timen +static inline void ndb_tsid_high(struct ndb_tsid *key, const unsigned char *id) +{ + memcpy(key->id, id, 32); + key->timestamp = UINT64_MAX; +} static int _ndb_begin_query(struct ndb *ndb, struct ndb_txn *txn, int flags) { @@ -1532,33 +1558,6 @@ static int ndb_tsid_compare(const MDB_val *a, const MDB_val *b) return 0; } -static inline void ndb_tsid_low(struct ndb_tsid *key, unsigned char *id) -{ - memcpy(key->id, id, 32); - key->timestamp = 0; -} - -static inline void ndb_tsid_init(struct ndb_tsid *key, unsigned char *id, - uint64_t timestamp) -{ - memcpy(key->id, id, 32); - key->timestamp = timestamp; -} - -static inline void ndb_u64_ts_init(struct ndb_u64_ts *key, uint64_t integer, - uint64_t timestamp) -{ - key->u64 = integer; - key->timestamp = timestamp; -} - -// useful for range-searching for the latest key with a clustered created_at timen -static inline void ndb_tsid_high(struct ndb_tsid *key, const unsigned char *id) -{ - memcpy(key->id, id, 32); - key->timestamp = UINT64_MAX; -} - enum ndb_ingester_msgtype { NDB_INGEST_EVENT, // write json to the ingester queue for processing NDB_INGEST_QUIT, // kill ingester thread immediately