mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
actually this is the real fix.
This commit is contained in:
parent
181234d774
commit
4ca8320e18
18
pool.go
18
pool.go
@ -263,13 +263,11 @@ func (pool *SimplePool) subMany(
|
||||
seenAlready := xsync.NewMapOf[string, Timestamp]()
|
||||
ticker := time.NewTicker(seenAlreadyDropTick)
|
||||
|
||||
eosed := false
|
||||
eoseWg := sync.WaitGroup{}
|
||||
eoseWg.Add(len(urls))
|
||||
if eoseChan != nil {
|
||||
go func() {
|
||||
eoseWg.Wait()
|
||||
eosed = true
|
||||
close(eoseChan)
|
||||
}()
|
||||
}
|
||||
@ -285,12 +283,18 @@ func (pool *SimplePool) subMany(
|
||||
continue
|
||||
}
|
||||
|
||||
eosed := false
|
||||
firstConnection := true
|
||||
|
||||
go func(nm string) {
|
||||
defer func() {
|
||||
pending.Dec()
|
||||
if pending.Value() == 0 {
|
||||
close(events)
|
||||
}
|
||||
if !eosed {
|
||||
eoseWg.Done()
|
||||
}
|
||||
cancel()
|
||||
}()
|
||||
|
||||
@ -319,8 +323,15 @@ func (pool *SimplePool) subMany(
|
||||
|
||||
relay, err := pool.EnsureRelay(nm)
|
||||
if err != nil {
|
||||
// if we never connected to this just fail
|
||||
if firstConnection {
|
||||
return
|
||||
}
|
||||
|
||||
// otherwise (if we were connected and got disconnected) keep trying to reconnect
|
||||
goto reconnect
|
||||
}
|
||||
firstConnection = false
|
||||
hasAuthed = false
|
||||
|
||||
subscribe:
|
||||
@ -340,6 +351,7 @@ func (pool *SimplePool) subMany(
|
||||
|
||||
// guard here otherwise a resubscription will trigger a duplicate call to eoseWg.Done()
|
||||
if !eosed {
|
||||
eosed = true
|
||||
eoseWg.Done()
|
||||
}
|
||||
}()
|
||||
@ -396,8 +408,6 @@ func (pool *SimplePool) subMany(
|
||||
log.Printf("CLOSED from %s: '%s'\n", nm, reason)
|
||||
}
|
||||
|
||||
eoseWg.Done()
|
||||
|
||||
return
|
||||
case <-ctx.Done():
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user