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
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

View File

@ -141,17 +141,13 @@ func (pool *SimplePool) subMany(ctx context.Context, urls []string, filters Filt
eose = true
case <-ticker.C:
if eose {
del := map[string]struct{}{}
old := Timestamp(time.Now().Add(-seenAlreadyDropTick).Unix())
seenAlready.Range(func(id string, value Timestamp) bool {
if value < old {
del[id] = struct{}{}
seenAlready.Delete(id)
}
return true
})
for k := range del {
seenAlready.Delete(k)
}
}
case reason := <-sub.ClosedReason:
log.Printf("CLOSED from %s: '%s'\n", nm, reason)