mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
problem: close channel to unsub is confusing
This commit is contained in:
parent
6f1c60f66c
commit
c94ae093c1
@ -38,7 +38,7 @@ go func() {
|
||||
}()
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
close(unsub)
|
||||
unsub()
|
||||
```
|
||||
|
||||
### Publishing an event
|
||||
|
@ -124,7 +124,7 @@ func (r *RelayPool) Remove(url string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RelayPool) Sub(filters Filters) (string, chan EventMessage, chan struct{}) {
|
||||
func (r *RelayPool) Sub(filters Filters) (string, chan EventMessage, func()) {
|
||||
random := make([]byte, 7)
|
||||
rand.Read(random)
|
||||
id := hex.EncodeToString(random)
|
||||
@ -154,7 +154,7 @@ func (r *RelayPool) Sub(filters Filters) (string, chan EventMessage, chan struct
|
||||
return true
|
||||
})
|
||||
|
||||
return id, eventStream, unsub
|
||||
return id, eventStream, func() { close(unsub) }
|
||||
}
|
||||
|
||||
func Unique(all chan EventMessage) chan Event {
|
||||
|
Loading…
x
Reference in New Issue
Block a user