aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/common/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/common/utils.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/common/utils.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/common/utils.go b/vendor/github.com/dexon-foundation/dexon-consensus/common/utils.go
index 7e89c059d..63d25a3fc 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/common/utils.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/common/utils.go
@@ -2,13 +2,20 @@ package common
import (
"math/rand"
+ "time"
)
+var random *rand.Rand
+
+func init() {
+ random = rand.New(rand.NewSource(time.Now().Unix()))
+}
+
// NewRandomHash returns a random Hash-like value.
func NewRandomHash() Hash {
x := Hash{}
for i := 0; i < HashLength; i++ {
- x[i] = byte(rand.Int() % 256)
+ x[i] = byte(random.Int() % 256)
}
return x
}