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

Check if the number of peers online > 0 before using peerClient
master
Poorna Krishnamoorthy 4 years ago committed by GitHub
parent d1a8f0b786
commit 845e251fa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      cmd/notification.go

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

Loading…
Cancel
Save