nostrdb: query: add missing since check to kind query
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
Daniel D’Aquino
parent
58de0025aa
commit
af5961ce26
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user