-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
As described in status-im/status-go#5759 (comment) by @igor-sirotin
The code as it is right now would allow publishing a message while not being subscribed to a pubsub topic.
I suggest either checking if a subscription to the pubsub topic before publishing and return an error or maybe attempt to subscribe with this code. I kinda prefer to return an error instead since then the user of the library can choose to subscribe or not depending on the error (and also because publishing without being subscribed does look like an incorrect usage of gowaku)
//Check if gossipsub subscription already exists for pubSubTopic
if !w.IsSubscribed(pubSubTopic) {
_, err := w.subscribeToPubsubTopic(cFilter.PubsubTopic)
if err != nil {
//TODO: Handle partial errors.
w.log.Error("failed to subscribe to pubsubTopic", zap.Error(err), zap.String("pubsubTopic", cFilter.PubsubTopic))
return nil, err
}
}
igor-sirotin
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
No status