commit af5961ce26b88e5b81fad209775807e594e6985a
parent 58de0025aa42afe73f478850f3677ba267678c64
Author: William Casarin <jb55@jb55.com>
Date: Mon, 30 Dec 2024 10:38:09 -0800
nostrdb: query: add missing since check to kind query
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c
@@ -3343,7 +3343,7 @@ static int ndb_query_plan_execute_kinds(struct ndb_txn *txn,
struct ndb_u64_ts tsid, *ptsid;
struct ndb_filter_elements *kinds;
struct ndb_query_result res;
- uint64_t kind, note_id, until, *pint;
+ uint64_t kind, note_id, until, since, *pint;
size_t note_size;
int i, rc;
@@ -3355,6 +3355,10 @@ static int ndb_query_plan_execute_kinds(struct ndb_txn *txn,
if ((pint = ndb_filter_get_int(filter, NDB_FILTER_UNTIL)))
until = *pint;
+ since = 0;
+ if ((pint = ndb_filter_get_int(filter, NDB_FILTER_SINCE)))
+ since = *pint;
+
db = txn->lmdb->dbs[NDB_DB_NOTE_KIND];
if ((rc = mdb_cursor_open(txn->mdb_txn, db, &cur)))
@@ -3380,6 +3384,10 @@ static int ndb_query_plan_execute_kinds(struct ndb_txn *txn,
if (ptsid->u64 != kind)
break;
+ // don't continue the scan if we're below `since`
+ if (ptsid->timestamp < since)
+ break;
+
note_id = *(uint64_t*)v.mv_data;
if (!(note = ndb_get_note_by_key(txn, note_id, ¬e_size)))
goto next;