diff --git a/waku/v2/node/subscription.go b/waku/v2/node/subscription.go new file mode 100644 index 00000000..1afe77b7 --- /dev/null +++ b/waku/v2/node/subscription.go @@ -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 +}