commit be1d149f4b65ab95e453d6613b387f13c3c0c0a0
parent 9e0dc47e9850daae9e48cb1ffe4ff650fcda6c18
Author: William Casarin <jb55@jb55.com>
Date: Fri, 13 Dec 2024 17:21:20 -0800
nostrdb: misc: move some functions around
because this will make the changes nicer
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/nostrdb/src/nostrdb.c b/nostrdb/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