Switch usage of math/rand to cmn's rand (#1980)

This commit switches all usage of math/rand to cmn's rand. The only
exceptions are within the random file itself, the tools package, and the
crypto package. In tools you don't want it to lock between the go-routines.
The crypto package doesn't use it so the crypto package have no other
dependencies within tendermint/tendermint for easier portability.

Crypto/rand usage is unadjusted.

Closes #1343
This commit is contained in:
Dev Ojha
2018-07-16 00:20:37 -07:00
committed by Anton Kaliaev
parent 14cebd181d
commit dae7dc30e0
10 changed files with 32 additions and 37 deletions

View File

@@ -3,7 +3,6 @@ package types
import (
"context"
"fmt"
"math/rand"
"testing"
"time"
@@ -150,7 +149,7 @@ func BenchmarkEventBus(b *testing.B) {
func benchmarkEventBus(numClients int, randQueries bool, randEvents bool, b *testing.B) {
// for random* functions
rand.Seed(time.Now().Unix())
cmn.Seed(time.Now().Unix())
eventBus := NewEventBusWithBufferCapacity(0) // set buffer capacity to 0 so we are not testing cache
eventBus.Start()
@@ -199,7 +198,7 @@ var events = []string{
EventVote}
func randEvent() string {
return events[rand.Intn(len(events))]
return events[cmn.RandIntn(len(events))]
}
var queries = []tmpubsub.Query{
@@ -217,5 +216,5 @@ var queries = []tmpubsub.Query{
EventQueryVote}
func randQuery() tmpubsub.Query {
return queries[rand.Intn(len(queries))]
return queries[cmn.RandIntn(len(queries))]
}