since and until are not pointers anymore because that is too annoying.

This commit is contained in:
fiatjaf
2025-05-08 09:32:54 -03:00
parent 0853405c03
commit c0934e0639
17 changed files with 55 additions and 85 deletions

View File

@@ -27,8 +27,8 @@ func prepareQueries(filter nostr.Filter) (
}
var until uint32 = 4294967295
if filter.Until != nil {
if fu := uint32(*filter.Until); fu < until {
if filter.Until != 0 {
if fu := uint32(filter.Until); fu < until {
until = fu + 1
}
}
@@ -38,8 +38,8 @@ func prepareQueries(filter nostr.Filter) (
}
// this is where we'll end the iteration
if filter.Since != nil {
if fs := uint32(*filter.Since); fs > since {
if filter.Since != 0 {
if fs := uint32(filter.Since); fs > since {
since = fs
}
}

View File

@@ -54,14 +54,14 @@ func (b *BlugeBackend) QueryEvents(filter nostr.Filter) iter.Seq[nostr.Event] {
q = complicatedQuery
}
if filter.Since != nil || filter.Until != nil {
if filter.Since != 0 || filter.Until != 0 {
min := 0.0
if filter.Since != nil {
min = float64(*filter.Since)
if filter.Since != 0 {
min = float64(filter.Since)
}
max := float64(nostr.Now())
if filter.Until != nil {
max = float64(*filter.Until)
if filter.Until != 0 {
max = float64(filter.Until)
}
dateRangeQ := bluge.NewNumericRangeInclusiveQuery(min, max, true, true)
dateRangeQ.SetField(createdAtField)

View File

@@ -36,8 +36,8 @@ func (b *LMDBBackend) prepareQueries(filter nostr.Filter) (
}
var until uint32 = 4294967295
if filter.Until != nil {
if fu := uint32(*filter.Until); fu < until {
if filter.Until != 0 {
if fu := uint32(filter.Until); fu < until {
until = fu + 1
}
}
@@ -62,8 +62,8 @@ func (b *LMDBBackend) prepareQueries(filter nostr.Filter) (
}
// this is where we'll end the iteration
if filter.Since != nil {
if fs := uint32(*filter.Since); fs > since {
if filter.Since != 0 {
if fs := uint32(filter.Since); fs > since {
since = fs
}
}

View File

@@ -36,8 +36,8 @@ func (il *IndexingLayer) prepareQueries(filter nostr.Filter) (
}
var until uint32 = 4294967295
if filter.Until != nil {
if fu := uint32(*filter.Until); fu < until {
if filter.Until != 0 {
if fu := uint32(filter.Until); fu < until {
until = fu + 1
}
}
@@ -51,8 +51,8 @@ func (il *IndexingLayer) prepareQueries(filter nostr.Filter) (
}()
// this is where we'll end the iteration
if filter.Since != nil {
if fs := uint32(*filter.Since); fs > since {
if filter.Since != 0 {
if fs := uint32(filter.Since); fs > since {
since = fs
}
}

View File

@@ -41,11 +41,11 @@ func (b *SliceStore) QueryEvents(filter nostr.Filter) iter.Seq[nostr.Event] {
// efficiently determine where to start and end
start := 0
end := len(b.internal)
if filter.Until != nil {
start, _ = slices.BinarySearchFunc(b.internal, *filter.Until, eventTimestampComparator)
if filter.Until != 0 {
start, _ = slices.BinarySearchFunc(b.internal, filter.Until, eventTimestampComparator)
}
if filter.Since != nil {
end, _ = slices.BinarySearchFunc(b.internal, *filter.Since, eventTimestampComparator)
if filter.Since != 0 {
end, _ = slices.BinarySearchFunc(b.internal, filter.Since, eventTimestampComparator)
}
// ham