extract subscription to separate file

This commit is contained in:
Richard Ramos 2021-04-14 22:17:12 -04:00
parent 9b7b942ac4
commit 547be3c951
No known key found for this signature in database
GPG Key ID: 80D4B01265FDFE8F
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package node
import (
"sync"
"github.com/status-im/go-waku/waku/common"
)
type Subscription struct {
C chan *common.Envelope
closed bool
mutex sync.Mutex
quit chan struct{}
}
func (subs *Subscription) Unsubscribe() {
if !subs.closed {
close(subs.quit)
}
}
func (subs *Subscription) IsClosed() bool {
subs.mutex.Lock()
defer subs.mutex.Unlock()
return subs.closed
}