From b85d2dc7f0009cd5fa0bf08c06ceec5fad223370 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sat, 13 May 2017 04:19:36 -0500 Subject: [PATCH] peer: Use prng to generate self detection nonce. This changes the nonce generated to detect self connections over to use pseudo randoms instead of a cryptographically random nonce. There is really not a good reason for it to be cryptographically strong, using the prng is much faster, and the prng also doesn't burn entropy. --- peer/peer.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/peer/peer.go b/peer/peer.go index 6cfe1738..1e272a2c 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -794,10 +794,7 @@ func (p *Peer) localVersionMsg() (*wire.MsgVersion, error) { // Generate a unique nonce for this peer so self connections can be // detected. This is accomplished by adding it to a size-limited map of // recently seen nonces. - nonce, err := wire.RandomUint64() - if err != nil { - return nil, err - } + nonce := uint64(rand.Int63()) sentNonces.Add(nonce) // Version message.