pool: bug that was causing a SubMany() to close if any of the relays failed to connect.
fixes https://github.com/nbd-wtf/go-nostr/issues/172
This commit is contained in:
4
pool.go
4
pool.go
@@ -254,7 +254,7 @@ func (pool *SimplePool) subMany(
|
|||||||
eoseChan chan struct{},
|
eoseChan chan struct{},
|
||||||
opts ...SubscriptionOption,
|
opts ...SubscriptionOption,
|
||||||
) chan RelayEvent {
|
) chan RelayEvent {
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancelCause(ctx)
|
||||||
_ = cancel // do this so `go vet` will stop complaining
|
_ = cancel // do this so `go vet` will stop complaining
|
||||||
events := make(chan RelayEvent)
|
events := make(chan RelayEvent)
|
||||||
seenAlready := xsync.NewMapOf[string, Timestamp]()
|
seenAlready := xsync.NewMapOf[string, Timestamp]()
|
||||||
@@ -288,11 +288,11 @@ func (pool *SimplePool) subMany(
|
|||||||
pending.Dec()
|
pending.Dec()
|
||||||
if pending.Value() == 0 {
|
if pending.Value() == 0 {
|
||||||
close(events)
|
close(events)
|
||||||
|
cancel(fmt.Errorf("aborted: %w", context.Cause(ctx)))
|
||||||
}
|
}
|
||||||
if !eosed {
|
if !eosed {
|
||||||
eoseWg.Done()
|
eoseWg.Done()
|
||||||
}
|
}
|
||||||
cancel()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
hasAuthed := false
|
hasAuthed := false
|
||||||
|
|||||||
Reference in New Issue
Block a user