fix quickselect.

This commit is contained in:
fiatjaf
2025-08-04 17:29:12 -03:00
parent 2750ae3751
commit 1cd48343d6
3 changed files with 120 additions and 45 deletions

View File

@@ -78,11 +78,9 @@ func (b *LMDBBackend) query(txn *lmdb.Txn, filter nostr.Filter, limit int, yield
// after pulling from all iterators once we now find out what iterators are
// the ones we should keep pulling from next (i.e. which one's last emitted timestamp is the highest)
iterators.quickselect(min(numberOfIteratorsToPullOnEachRound, len(iterators)), 0, len(iterators))
threshold := iterators.quickselect(min(numberOfIteratorsToPullOnEachRound, len(iterators)))
// we now know what is our threshold
threshold := iterators[len(iterators)-1].last
// so we can emit all the events higher than it
// so we can emit all the events higher than the threshold
for _, it := range iterators {
for t, ts := range it.timestamps {
if ts >= threshold {