mirror of https://github.com/status-im/go-waku.git
fix: flaky panic on relay unsubscribe (#1201)
This commit is contained in:
parent
8ff8779bb0
commit
1472b17d39
|
@ -459,16 +459,14 @@ func (w *WakuRelay) Unsubscribe(ctx context.Context, contentFilter waku_proto.Co
|
|||
defer w.topicsMutex.Unlock()
|
||||
|
||||
for pubSubTopic, cTopics := range pubSubTopicMap {
|
||||
cfTemp := waku_proto.NewContentFilter(pubSubTopic, cTopics...)
|
||||
pubsubUnsubscribe := false
|
||||
sub, ok := w.topics[pubSubTopic]
|
||||
topicData, ok := w.topics[pubSubTopic]
|
||||
if !ok {
|
||||
w.log.Error("not subscribed to topic", zap.String("topic", pubSubTopic))
|
||||
return errors.New("not subscribed to topic")
|
||||
}
|
||||
|
||||
topicData, ok := w.topics[pubSubTopic]
|
||||
if ok {
|
||||
cfTemp := waku_proto.NewContentFilter(pubSubTopic, cTopics...)
|
||||
//Remove relevant subscription
|
||||
for subID, sub := range topicData.contentSubs {
|
||||
if sub.contentFilter.Equals(cfTemp) {
|
||||
|
@ -480,16 +478,9 @@ func (w *WakuRelay) Unsubscribe(ctx context.Context, contentFilter waku_proto.Co
|
|||
if len(topicData.contentSubs) == 0 {
|
||||
pubsubUnsubscribe = true
|
||||
}
|
||||
} else {
|
||||
//Should not land here ideally
|
||||
w.log.Error("pubsub subscriptions exists, but contentSubscription doesn't for contentFilter",
|
||||
zap.String("pubsubTopic", pubSubTopic), zap.Strings("contentTopics", cTopics))
|
||||
|
||||
return errors.New("unexpected error in unsubscribe")
|
||||
}
|
||||
|
||||
if pubsubUnsubscribe {
|
||||
err = w.unsubscribeFromPubsubTopic(sub)
|
||||
err = w.unsubscribeFromPubsubTopic(topicData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue