filter.GetTheoreticalLimit() to encompass the actual limit specified in the filter.

This commit is contained in:
fiatjaf
2025-12-19 06:52:46 -03:00
parent 14dcc01f8f
commit daee8575d9
7 changed files with 23 additions and 20 deletions

View File

@@ -29,8 +29,10 @@ func (b *SliceStore) Close() {}
func (b *SliceStore) QueryEvents(filter nostr.Filter, maxLimit int) iter.Seq[nostr.Event] {
return func(yield func(nostr.Event) bool) {
if filter.Limit > maxLimit || (filter.Limit == 0 && !filter.LimitZero) {
filter.Limit = maxLimit
if tlimit := filter.GetTheoreticalLimit(); tlimit == 0 {
return
} else if tlimit < maxLimit {
maxLimit = tlimit
}
// efficiently determine where to start and end
@@ -50,7 +52,7 @@ func (b *SliceStore) QueryEvents(filter nostr.Filter, maxLimit int) iter.Seq[nos
count := 0
for _, event := range b.internal[start:end] {
if count == filter.Limit {
if count == maxLimit {
break
}