seed mrand

This commit is contained in:
Andrea Maria Piana 2020-08-27 15:30:48 +02:00
parent 2ef1aa89f4
commit 4a87764cca
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
3 changed files with 7 additions and 1 deletions

View File

@ -91,7 +91,7 @@ func (n *testNode) GetWhisper(_ interface{}) (types.Whisper, error) {
return nil, nil
}
func (c *testNode) PeersCount() int {
func (n *testNode) PeersCount() int {
return 1
}

View File

@ -319,6 +319,7 @@ func (c *Client) pickDefaultServers(servers []*ecdsa.PublicKey) []*ecdsa.PublicK
// shuffle and pick n at random
shuffledServers := make([]*ecdsa.PublicKey, len(servers))
copy(shuffledServers, c.config.DefaultServers)
mrand.Seed(time.Now().Unix())
mrand.Shuffle(len(shuffledServers), func(i, j int) {
shuffledServers[i], shuffledServers[j] = shuffledServers[j], shuffledServers[i]
})
@ -1151,6 +1152,7 @@ func (c *Client) sendNotification(publicKey *ecdsa.PublicKey, installationIDs []
// NOTE: here's is a tradeoff, ideally we want to randomly pick a server,
// but hit the same servers for batched notifications, for now naively
// hit a random server
mrand.Seed(time.Now().Unix())
mrand.Shuffle(len(info), func(i, j int) {
info[i], info[j] = info[j], info[i]
})

View File

@ -28,6 +28,10 @@ func (w *TestNodeWrapper) GetWaku(_ interface{}) (types.Waku, error) {
return w.waku, nil
}
func (w *TestNodeWrapper) PeersCount() int {
return 1
}
func (w *TestNodeWrapper) AddPeer(url string) error {
panic("not implemented")
}