fix: prevent panics in peermanager and WakuRelay (#1206)

This commit is contained in:
Igor Sirotin 2024-08-23 15:23:07 +01:00 committed by GitHub
parent a4f0cae911
commit 4c3ec60da5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -125,6 +125,10 @@ func inAndOutRelayPeers(relayPeers int) (int, int) {
// checkAndUpdateTopicHealth finds health of specified topic and updates and notifies of the same.
// Also returns the healthyPeerCount
func (pm *PeerManager) checkAndUpdateTopicHealth(topic *NodeTopicDetails) int {
if topic == nil {
return 0
}
healthyPeerCount := 0
for _, p := range pm.relay.PubSub().MeshPeers(topic.topic.String()) {

View File

@ -493,6 +493,9 @@ func (w *WakuRelay) Unsubscribe(ctx context.Context, contentFilter waku_proto.Co
// unsubscribeFromPubsubTopic unsubscribes subscription from underlying pubsub.
// Note: caller has to acquire topicsMutex in order to avoid race conditions
func (w *WakuRelay) unsubscribeFromPubsubTopic(topicData *pubsubTopicSubscriptionDetails) error {
if topicData.subscription == nil {
return nil
}
pubSubTopic := topicData.subscription.Topic()
w.log.Info("unsubscribing from pubsubTopic", zap.String("topic", pubSubTopic))