Skip to content

Commit

Permalink
fix: notify Waku Metadata when Waku Filter subscribe to a topic (#2493)
Browse files Browse the repository at this point in the history
  • Loading branch information
SionoiS authored Mar 1, 2024
1 parent 0a75122 commit 91e3f8c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions waku/node/waku_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ proc filterSubscribe*(node: WakuNode,
let subRes = await node.wakuFilterClient.subscribe(remotePeer, pubsubTopic.get(), contentTopics)
if subRes.isOk():
info "v2 subscribed to topic", pubsubTopic=pubsubTopic, contentTopics=contentTopics

# Purpose is to update Waku Metadata
node.topicSubscriptionQueue.emit((kind: PubsubSub, topic: pubsubTopic.get()))
else:
error "failed filter v2 subscription", error=subRes.error
waku_node_errors.inc(labelValues = ["subscribe_filter_failure"])
Expand Down Expand Up @@ -605,6 +608,9 @@ proc filterSubscribe*(node: WakuNode,
for pubsub, topics in topicMap.pairs:
info "subscribed to topic", pubsubTopic=pubsub, contentTopics=topics

# Purpose is to update Waku Metadata
node.topicSubscriptionQueue.emit((kind: PubsubSub, topic: $pubsub))

# return the last error or ok
return subRes

Expand Down Expand Up @@ -689,6 +695,9 @@ proc filterUnsubscribe*(node: WakuNode,
let unsubRes = await node.wakuFilterClient.unsubscribe(remotePeer, pubsubTopic.get(), contentTopics)
if unsubRes.isOk():
info "unsubscribed from topic", pubsubTopic=pubsubTopic.get(), contentTopics=contentTopics

# Purpose is to update Waku Metadata
node.topicSubscriptionQueue.emit((kind: PubsubUnsub, topic: pubsubTopic.get()))
else:
error "failed filter unsubscription", error=unsubRes.error
waku_node_errors.inc(labelValues = ["unsubscribe_filter_failure"])
Expand Down Expand Up @@ -724,6 +733,9 @@ proc filterUnsubscribe*(node: WakuNode,
for pubsub, topics in topicMap.pairs:
info "unsubscribed from topic", pubsubTopic=pubsub, contentTopics=topics

# Purpose is to update Waku Metadata
node.topicSubscriptionQueue.emit((kind: PubsubUnsub, topic: $pubsub))

# return the last error or ok
return unsubRes

Expand Down

0 comments on commit 91e3f8c

Please sign in to comment.