dry sub.unsub() on context cancelation.

This commit is contained in:
fiatjaf 2023-03-18 16:07:19 -03:00
parent e9ad77c822
commit 46e724b8d5
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

View File

@ -86,11 +86,7 @@ func (sub *Subscription) Fire(ctx context.Context) error {
go func() {
<-sub.Relay.ConnectionContext.Done()
// this will close the Events channel,
// which can be used by an external reader to learn the subscription has stopped
sub.Unsub()
// we also cancel the context
// cancel the context -- this will cause the other context cancelation cause above to be called
cancel()
}()