mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-05-05 00:00:14 +02: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 {
|
for _, url := range urls {
|
||||||
go func(nm string) {
|
go func(nm string) {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
relay, err := pool.EnsureRelay(nm)
|
relay, err := pool.EnsureRelay(nm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -115,14 +117,13 @@ func (pool *SimplePool) SubManyEose(ctx context.Context, urls []string, filters
|
|||||||
|
|
||||||
sub, _ := relay.Subscribe(ctx, filters)
|
sub, _ := relay.Subscribe(ctx, filters)
|
||||||
if sub == nil {
|
if sub == nil {
|
||||||
wg.Done()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
case <-sub.EndOfStoredEvents:
|
case <-sub.EndOfStoredEvents:
|
||||||
return
|
return
|
||||||
case evt, more := <-sub.Events:
|
case evt, more := <-sub.Events:
|
||||||
@ -132,7 +133,11 @@ func (pool *SimplePool) SubManyEose(ctx context.Context, urls []string, filters
|
|||||||
|
|
||||||
// dispatch unique events to client
|
// dispatch unique events to client
|
||||||
if _, ok := seenAlready.LoadOrStore(evt.ID, true); !ok {
|
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