mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-04 06:53:06 +00:00
fix: concurrent write on relay rpc/rest
This commit is contained in:
parent
2f009cb69f
commit
50e0e803eb
@ -71,11 +71,13 @@ func (r *RelayService) Start(ctx context.Context) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
r.cancel = cancel
|
||||
|
||||
r.messagesMutex.Lock()
|
||||
// Node may already be subscribed to some topics when Relay API handlers are installed. Let's add these
|
||||
for _, topic := range r.node.Relay().Topics() {
|
||||
r.log.Info("adding topic handler for existing subscription", zap.String("topic", topic))
|
||||
r.messages[topic] = []*pb.WakuMessage{}
|
||||
}
|
||||
r.messagesMutex.Unlock()
|
||||
|
||||
r.runner.Start(ctx)
|
||||
}
|
||||
|
||||
@ -67,11 +67,13 @@ func (r *RelayService) addEnvelope(envelope *protocol.Envelope) {
|
||||
}
|
||||
|
||||
func (r *RelayService) Start() {
|
||||
r.messagesMutex.Lock()
|
||||
// Node may already be subscribed to some topics when Relay API handlers are installed. Let's add these
|
||||
for _, topic := range r.node.Relay().Topics() {
|
||||
r.log.Info("adding topic handler for existing subscription", zap.String("topic", topic))
|
||||
r.messages[topic] = make([]*pb.WakuMessage, 0)
|
||||
}
|
||||
r.messagesMutex.Unlock()
|
||||
|
||||
r.runner.Start()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user