fix: panic during removePubSubTopic (#765)

This commit is contained in:
Prem Chaitanya Prathi 2023-09-22 17:36:45 +05:30 committed by GitHub
parent a84701abaa
commit 9f4754dcae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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