util: drop RandUint32()

I don't see anything useful in it, all the current users of it should just use
plain rand.Uint32() not limiting its output in any way.
This commit is contained in:
Roman Khimov 2019-08-23 18:19:07 +03:00
parent 3fa6ba9c7b
commit 2fd782eee8
3 changed files with 8 additions and 18 deletions

View file

@ -1,6 +1,7 @@
package network
import (
"math/rand"
"testing"
"time"
@ -149,7 +150,7 @@ func newTestServer() *Server {
chain: testChain{},
transport: localTransport{},
discovery: testDiscovery{},
id: util.RandUint32(1000000, 9999999),
id: rand.Uint32(),
quit: make(chan struct{}),
register: make(chan Peer),
unregister: make(chan peerDrop),

View file

@ -3,6 +3,7 @@ package network
import (
"errors"
"fmt"
"math/rand"
"sync"
"time"
@ -61,7 +62,7 @@ func NewServer(config ServerConfig, chain core.Blockchainer) *Server {
s := &Server{
ServerConfig: config,
chain: chain,
id: util.RandUint32(1000000, 9999999),
id: rand.Uint32(),
quit: make(chan struct{}),
register: make(chan Peer),
unregister: make(chan peerDrop),
@ -349,3 +350,7 @@ func (s *Server) RelayDirectly(p Peer, inv *payload.Inventory) {
p.WriteMsg(NewMessage(s.Net, CMDInv, inv))
}
func init() {
rand.Seed(time.Now().UTC().UnixNano())
}

View file

@ -1,16 +0,0 @@
package util
import (
"math/rand"
"time"
)
// RandUint32 return a random number between min and max.
func RandUint32(min, max int) uint32 {
n := min + rand.Intn(max-min)
return uint32(n)
}
func init() {
rand.Seed(time.Now().UTC().UnixNano())
}