simplify pre-eose cleanup in pool.subMany()

This commit is contained in:
fiatjaf
2023-12-02 14:37:32 -03:00
parent cb8b40bd00
commit 32c1969397
+1 -5
View File
@@ -141,17 +141,13 @@ func (pool *SimplePool) subMany(ctx context.Context, urls []string, filters Filt
eose = true eose = true
case <-ticker.C: case <-ticker.C:
if eose { if eose {
del := map[string]struct{}{}
old := Timestamp(time.Now().Add(-seenAlreadyDropTick).Unix()) old := Timestamp(time.Now().Add(-seenAlreadyDropTick).Unix())
seenAlready.Range(func(id string, value Timestamp) bool { seenAlready.Range(func(id string, value Timestamp) bool {
if value < old { if value < old {
del[id] = struct{}{} seenAlready.Delete(id)
} }
return true return true
}) })
for k := range del {
seenAlready.Delete(k)
}
} }
case reason := <-sub.ClosedReason: case reason := <-sub.ClosedReason:
log.Printf("CLOSED from %s: '%s'\n", nm, reason) log.Printf("CLOSED from %s: '%s'\n", nm, reason)