mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-29 11:12:04 +01:00
problem: panic if calling unsub more than once
problem: panic if calling unsub more than once It's a bit dangerous if calling unsub more than once causes a fatal panic.
This commit is contained in:
parent
3f2c3f1bd8
commit
bb1138a2fa
10
relaypool.go
10
relaypool.go
@ -157,7 +157,15 @@ func (r *RelayPool) Sub(filters Filters) (subID string, events chan EventMessage
|
||||
return true
|
||||
})
|
||||
|
||||
return id, eventStream, func() { close(unsub) }
|
||||
return id, eventStream, func() { gracefulClose(unsub) }
|
||||
}
|
||||
|
||||
func gracefulClose(c chan struct{}) {
|
||||
select {
|
||||
case <-c:
|
||||
default:
|
||||
close(c)
|
||||
}
|
||||
}
|
||||
|
||||
func Unique(all chan EventMessage) chan Event {
|
||||
|
Loading…
x
Reference in New Issue
Block a user