mirror of https://github.com/status-im/go-waku.git
fix: concurrent map writes
This commit is contained in:
parent
5f65c5a9f4
commit
861f37f15a
|
@ -128,8 +128,9 @@ func (d *RelayService) postV1Subscriptions(w http.ResponseWriter, r *http.Reques
|
|||
d.log.Error("subscribing to topic", zap.String("topic", strings.Replace(topicToSubscribe, "\n", "", -1)), zap.Error(err))
|
||||
} else {
|
||||
d.node.Broadcaster().Unregister(&topicToSubscribe, sub.C)
|
||||
|
||||
d.messagesMutex.Lock()
|
||||
d.messages[topic] = []*pb.WakuMessage{}
|
||||
d.messagesMutex.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,9 @@ func (r *RelayService) PostV1Subscription(req *http.Request, args *TopicsArgs, r
|
|||
r.log.Error("subscribing to topic", zap.String("topic", topic), zap.Error(err))
|
||||
return err
|
||||
}
|
||||
r.messagesMutex.Lock()
|
||||
r.messages[topic] = make([]*pb.WakuMessage, 0)
|
||||
r.messagesMutex.Unlock()
|
||||
}
|
||||
|
||||
*reply = true
|
||||
|
|
Loading…
Reference in New Issue