clear context differentiation on submany/unique.

This commit is contained in:
fiatjaf 2023-10-03 15:43:18 -03:00
parent 7d1091b66b
commit edefc57b28
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

32
pool.go
View File

@ -86,17 +86,17 @@ func (pool *SimplePool) subMany(ctx context.Context, urls []string, filters Filt
}
for evt := range sub.Events {
stop := false
if unique {
_, stop = seenAlready.LoadOrStore(evt.ID, true)
}
if !stop {
select {
case events <- IncomingEvent{Event: evt, Relay: relay}:
case <-ctx.Done():
return
if _, seen := seenAlready.LoadOrStore(evt.ID, true); seen {
continue
}
}
select {
case events <- IncomingEvent{Event: evt, Relay: relay}:
case <-ctx.Done():
return
}
}
pending.Dec()
@ -160,17 +160,17 @@ func (pool *SimplePool) subManyEose(ctx context.Context, urls []string, filters
return
}
stop := false
if unique {
_, stop = seenAlready.LoadOrStore(evt.ID, true)
}
if !stop {
select {
case events <- IncomingEvent{Event: evt, Relay: relay}:
case <-ctx.Done():
return
if _, seen := seenAlready.LoadOrStore(evt.ID, true); seen {
continue
}
}
select {
case events <- IncomingEvent{Event: evt, Relay: relay}:
case <-ctx.Done():
return
}
}
}
}(NormalizeURL(url))