mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-13 23:34:54 +00:00
fix(c-bindings): relayTopics should trigger signal handler
This commit is contained in:
parent
20f310a815
commit
4804588197
@ -272,13 +272,11 @@ func Start() string {
|
||||
}
|
||||
|
||||
for _, topic := range wakuState.relayTopics {
|
||||
topic := topic
|
||||
sub, err := wakuState.node.Relay().SubscribeToTopic(wakuState.ctx, topic)
|
||||
err := relaySubscribe(topic)
|
||||
if err != nil {
|
||||
wakuState.node.Stop()
|
||||
return MakeJSONResponse(fmt.Errorf("could not subscribe to topic: %s, %w", topic, err))
|
||||
return MakeJSONResponse(err)
|
||||
}
|
||||
wakuState.node.Broadcaster().Unregister(&topic, sub.C)
|
||||
}
|
||||
|
||||
return MakeJSONResponse(nil)
|
||||
|
@ -79,11 +79,7 @@ func RelayPublishEncodeSymmetric(messageJSON string, topic string, symmetricKey
|
||||
return PrepareJSONResponse(hash, err)
|
||||
}
|
||||
|
||||
func RelaySubscribe(topic string) string {
|
||||
if wakuState.node == nil {
|
||||
return MakeJSONResponse(errWakuNodeNotReady)
|
||||
}
|
||||
|
||||
func relaySubscribe(topic string) error {
|
||||
topicToSubscribe := getTopic(topic)
|
||||
|
||||
relaySubsMutex.Lock()
|
||||
@ -91,12 +87,12 @@ func RelaySubscribe(topic string) string {
|
||||
|
||||
_, ok := relaySubscriptions[topicToSubscribe]
|
||||
if ok {
|
||||
return MakeJSONResponse(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
subscription, err := wakuState.node.Relay().SubscribeToTopic(context.Background(), topicToSubscribe)
|
||||
if err != nil {
|
||||
return MakeJSONResponse(err)
|
||||
return err
|
||||
}
|
||||
|
||||
relaySubscriptions[topicToSubscribe] = subscription
|
||||
@ -107,7 +103,15 @@ func RelaySubscribe(topic string) string {
|
||||
}
|
||||
}(subscription)
|
||||
|
||||
return MakeJSONResponse(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func RelaySubscribe(topic string) string {
|
||||
if wakuState.node == nil {
|
||||
return MakeJSONResponse(errWakuNodeNotReady)
|
||||
}
|
||||
|
||||
return MakeJSONResponse(relaySubscribe(topic))
|
||||
}
|
||||
|
||||
func RelayUnsubscribe(topic string) string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user