fix: crash in notificationsys when peers online is 0 (#11307)

Check if the number of peers online > 0 before using peerClient
This commit is contained in:
Poorna Krishnamoorthy
2021-01-20 13:13:05 -08:00
committed by GitHub
parent d1a8f0b786
commit 845e251fa9

View File

@@ -1276,6 +1276,9 @@ func (sys *NotificationSys) restClientFromHash(s string) (client *peerRESTClient
return nil
}
peerClients := sys.getOnlinePeers()
if len(peerClients) == 0 {
return nil
}
idx := xxhash.Sum64String(s) % uint64(len(peerClients))
return peerClients[idx]
}