From 9f4754dcae656bf15a3982fb214b46e7755bd9e0 Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Fri, 22 Sep 2023 17:36:45 +0530 Subject: [PATCH] fix: panic during removePubSubTopic (#765) --- waku/v2/peerstore/waku_peer_store.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/waku/v2/peerstore/waku_peer_store.go b/waku/v2/peerstore/waku_peer_store.go index 00c812c5..df80df88 100644 --- a/waku/v2/peerstore/waku_peer_store.go +++ b/waku/v2/peerstore/waku_peer_store.go @@ -171,8 +171,12 @@ func (ps *WakuPeerstoreImpl) RemovePubSubTopic(p peer.ID, topic string) error { } for i := range existingTopics { - existingTopics = append(existingTopics[:i], existingTopics[i+1:]...) + if existingTopics[i] == topic { + existingTopics = append(existingTopics[:i], existingTopics[i+1:]...) + break + } } + err = ps.SetPubSubTopics(p, existingTopics) if err != nil { return err