mirror of https://github.com/status-im/go-waku.git
refactor: extract function to subscribe to topic
This commit is contained in:
parent
13aee0b1e0
commit
578b40a44e
|
@ -389,7 +389,12 @@ func (node *WakuNode) Subscribe(ctx context.Context, topic *relay.Topic) (*Subsc
|
|||
|
||||
node.bcaster.Register(subscription.C)
|
||||
|
||||
go func(t relay.Topic) {
|
||||
go node.subscribeToTopic(t, subscription, sub)
|
||||
|
||||
return subscription, nil
|
||||
}
|
||||
|
||||
func (node *WakuNode) subscribeToTopic(t relay.Topic, subscription *Subscription, sub *pubsub.Subscription) {
|
||||
nextMsgTicker := time.NewTicker(time.Millisecond * 10)
|
||||
defer nextMsgTicker.Stop()
|
||||
|
||||
|
@ -430,9 +435,6 @@ func (node *WakuNode) Subscribe(ctx context.Context, topic *relay.Topic) (*Subsc
|
|||
node.bcaster.Submit(envelope)
|
||||
}
|
||||
}
|
||||
}(t)
|
||||
|
||||
return subscription, nil
|
||||
}
|
||||
|
||||
// Wrapper around WakuFilter.Subscribe
|
||||
|
|
Loading…
Reference in New Issue