Pseudorandom Number Generator
A transaction that generates a pseudorandom number. When the pseudorandom number generate transaction executes, its transaction record will contain the 384-bit array of pseudorandom bytes. The transaction has an optional
rangeparameter. If the parameter is given and is positive, then the record will contain a 32-bit pseudorandom integer
0 <= r < rangeinstead of containing the 384 pseudorandom bits.
nth transaction needs a pseudorandom number, it is given the running hash of all records up to and including the record for transaction
n-3. If it needs 384 bits, then it uses the entire hash. If it needs 256 bits, it uses the first 256 bits of the hash. If it needs a random number
rthat is in the range
0 <= r < range, then it lets
xbe the first 32 bits of the hash (interpreted as a signed integer).
The choice of using the hash up to transaction
n-1is to ensure the transactions can be processed quickly. Because the thread calculating the hash will have more time to complete it before it is needed. The use of
n-1000000is to make it hard to predict the pseudorandom number in advance.\
The specified range to return the pseudorandom number from.