[#851] util/rand: use single random source

It is much more convenient to skip source creation.
Also fix some bugs:
1. `cryptoSource.Int63()` now returns number in [0, 1<<63) as required
   by `rand.Source` interface.
2. Replace `cryptoSource.Uint63()` with `cryptoSource.Uint64` to allow
   generate uint64 numbers directly (see rand.Source64 docs).

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-01-11 17:07:59 +03:00 committed by Alex Vanin
parent c35cdb3684
commit 5828f43e52
8 changed files with 56 additions and 66 deletions

View file

@ -361,9 +361,6 @@ func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce ui
return c.notaryInvoke(false, true, contract, nonce, vub, method, args...)
}
// randSource is a source of random numbers.
var randSource = rand.New()
// NotaryInvokeNotAlpha does the same as NotaryInvoke but does not use client's
// private key in Invocation script. It means that main TX of notary request is
// not expected to be signed by the current node.
@ -380,7 +377,7 @@ func (c *Client) NotaryInvokeNotAlpha(contract util.Uint160, fee fixedn.Fixed8,
return c.Invoke(contract, fee, method, args...)
}
return c.notaryInvoke(false, false, contract, randSource.Uint32(), nil, method, args...)
return c.notaryInvoke(false, false, contract, rand.Uint32(), nil, method, args...)
}
// NotarySignAndInvokeTX signs and sends notary request that was received from