mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
fix SubMany() global eosed tracking and SubManyNotifyEOSE() proper notification.
This commit is contained in:
parent
78a9411d8a
commit
181234d774
8
pool.go
8
pool.go
@ -263,12 +263,13 @@ func (pool *SimplePool) subMany(
|
||||
seenAlready := xsync.NewMapOf[string, Timestamp]()
|
||||
ticker := time.NewTicker(seenAlreadyDropTick)
|
||||
|
||||
eose := false
|
||||
eosed := false
|
||||
eoseWg := sync.WaitGroup{}
|
||||
eoseWg.Add(len(urls))
|
||||
if eoseChan != nil {
|
||||
go func() {
|
||||
eoseWg.Wait()
|
||||
eosed = true
|
||||
close(eoseChan)
|
||||
}()
|
||||
}
|
||||
@ -338,8 +339,7 @@ func (pool *SimplePool) subMany(
|
||||
<-sub.EndOfStoredEvents
|
||||
|
||||
// guard here otherwise a resubscription will trigger a duplicate call to eoseWg.Done()
|
||||
if !eose {
|
||||
eose = true
|
||||
if !eosed {
|
||||
eoseWg.Done()
|
||||
}
|
||||
}()
|
||||
@ -374,7 +374,7 @@ func (pool *SimplePool) subMany(
|
||||
return
|
||||
}
|
||||
case <-ticker.C:
|
||||
if eose {
|
||||
if eosed {
|
||||
old := Timestamp(time.Now().Add(-seenAlreadyDropTick).Unix())
|
||||
for id, value := range seenAlready.Range {
|
||||
if value < old {
|
||||
|
Loading…
x
Reference in New Issue
Block a user