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:
fiatjaf 2025-02-12 14:32:22 -03:00
parent 3de002aca1
commit e0ed40613d

View File

@ -254,7 +254,7 @@ func (pool *SimplePool) subMany(
eoseChan chan struct{},
opts ...SubscriptionOption,
) chan RelayEvent {
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithCancelCause(ctx)
_ = cancel // do this so `go vet` will stop complaining
events := make(chan RelayEvent)
seenAlready := xsync.NewMapOf[string, Timestamp]()
@ -288,11 +288,11 @@ func (pool *SimplePool) subMany(
pending.Dec()
if pending.Value() == 0 {
close(events)
cancel(fmt.Errorf("aborted: %w", context.Cause(ctx)))
}
if !eosed {
eoseWg.Done()
}
cancel()
}()
hasAuthed := false