diff --git a/pkg/network/helper_test.go b/pkg/network/helper_test.go index 9bb6803b1..bdf6a9c83 100644 --- a/pkg/network/helper_test.go +++ b/pkg/network/helper_test.go @@ -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), diff --git a/pkg/network/server.go b/pkg/network/server.go index f6e9f4416..d6e260956 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -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()) +} diff --git a/pkg/util/random.go b/pkg/util/random.go deleted file mode 100644 index 0ea02d4d9..000000000 --- a/pkg/util/random.go +++ /dev/null @@ -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()) -}