mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
prevent halting on SubManyEose.
This commit is contained in:
parent
9b2b3b9039
commit
82a51f149a
13
pool.go
13
pool.go
@ -108,6 +108,8 @@ func (pool *SimplePool) SubManyEose(ctx context.Context, urls []string, filters
|
||||
|
||||
for _, url := range urls {
|
||||
go func(nm string) {
|
||||
defer wg.Done()
|
||||
|
||||
relay, err := pool.EnsureRelay(nm)
|
||||
if err != nil {
|
||||
return
|
||||
@ -115,14 +117,13 @@ func (pool *SimplePool) SubManyEose(ctx context.Context, urls []string, filters
|
||||
|
||||
sub, _ := relay.Subscribe(ctx, filters)
|
||||
if sub == nil {
|
||||
wg.Done()
|
||||
return
|
||||
}
|
||||
|
||||
defer wg.Done()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-sub.EndOfStoredEvents:
|
||||
return
|
||||
case evt, more := <-sub.Events:
|
||||
@ -132,7 +133,11 @@ func (pool *SimplePool) SubManyEose(ctx context.Context, urls []string, filters
|
||||
|
||||
// dispatch unique events to client
|
||||
if _, ok := seenAlready.LoadOrStore(evt.ID, true); !ok {
|
||||
uniqueEvents <- evt
|
||||
select {
|
||||
case uniqueEvents <- evt:
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user