mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-07 21:49:16 +02: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]()
|
seenAlready := xsync.NewMapOf[string, Timestamp]()
|
||||||
ticker := time.NewTicker(seenAlreadyDropTick)
|
ticker := time.NewTicker(seenAlreadyDropTick)
|
||||||
|
|
||||||
eose := false
|
eosed := false
|
||||||
eoseWg := sync.WaitGroup{}
|
eoseWg := sync.WaitGroup{}
|
||||||
eoseWg.Add(len(urls))
|
eoseWg.Add(len(urls))
|
||||||
if eoseChan != nil {
|
if eoseChan != nil {
|
||||||
go func() {
|
go func() {
|
||||||
eoseWg.Wait()
|
eoseWg.Wait()
|
||||||
|
eosed = true
|
||||||
close(eoseChan)
|
close(eoseChan)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -338,8 +339,7 @@ func (pool *SimplePool) subMany(
|
|||||||
<-sub.EndOfStoredEvents
|
<-sub.EndOfStoredEvents
|
||||||
|
|
||||||
// guard here otherwise a resubscription will trigger a duplicate call to eoseWg.Done()
|
// guard here otherwise a resubscription will trigger a duplicate call to eoseWg.Done()
|
||||||
if !eose {
|
if !eosed {
|
||||||
eose = true
|
|
||||||
eoseWg.Done()
|
eoseWg.Done()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -374,7 +374,7 @@ func (pool *SimplePool) subMany(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if eose {
|
if eosed {
|
||||||
old := Timestamp(time.Now().Add(-seenAlreadyDropTick).Unix())
|
old := Timestamp(time.Now().Add(-seenAlreadyDropTick).Unix())
|
||||||
for id, value := range seenAlready.Range {
|
for id, value := range seenAlready.Range {
|
||||||
if value < old {
|
if value < old {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user