Open richard-ramos opened 2 months ago
I found this piece of code which check similar logic, wondering why is it not working in this case? https://github.com/waku-org/go-waku/blob/master/waku/v2/protocol/relay/waku_relay.go#L285
wondering why is it not working in this case?
I think it works 🙂 Check the logs I attached in https://github.com/status-im/status-go/issues/5759#issuecomment-2305818102 - could not send message: not enough peers to publish
.
The question is, should we maybe auto-subscribe to topic in such case.
should we maybe auto-subscribe to topic in such case.
It seems we need a wrapper API for auto subscribe. what do you think? @richard-ramos
should we maybe auto-subscribe to topic in such case.
It seems we need a wrapper API for auto subscribe. what do you think? @richard-ramos
it may not be so straight-forward, because when you subscribe to a pubsubtopic doesn't mean you have peers connected wrt topic. So, doing it as part of publish may not solve the issue rather mislead further.
either we subscribe and wait to have atleast 1 peer for topic(which itself is not gauranteed msg will be reliably propagated). or return an error so that caller can subscribe to topic and wait for it to be healthy before publishing. wondering if we ca use topic-health to decide whether to publish or not rather than min-peers. wdyt @richard-ramos
I agree with Prem's observations about creating a wrapper not being straightforward. Subscribing to the principle of least surprise, i'd rather have the publish function return an error and handle it appropriately.
wondering if we ca use topic-health to decide whether to publish or not rather than min-peers
IMO yes. Using topic health is a pending topic we have for go-waku / status-go integration, so perhaps this is a good moment to work on this task!
As described in https://github.com/status-im/status-go/issues/5759#issuecomment-2305221720 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)