Update shuffling comments

This commit is contained in:
Paul Hauner 2018-10-03 13:43:46 +10:00
parent 2763f7bc00
commit 6d4a3bba11
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
2 changed files with 11 additions and 6 deletions

View File

@ -1,2 +0,0 @@
This module includes the fundamental shuffling function. It does not do the
full validator delegation amongst slots.

View File

@ -1,3 +1,7 @@
/// A library for performing deterministic, pseudo-random shuffling on a vector.
///
/// This library is designed to confirm to the Ethereum 2.0 specification.
extern crate hashing;
mod rng;
@ -9,13 +13,16 @@ pub enum ShuffleErr {
ExceedsListLength,
}
/// Performs a deterministic, in-place shuffle of a vector of bytes.
/// Performs a deterministic, in-place shuffle of a vector.
///
/// The final order of the shuffle is determined by successive hashes
/// of the supplied `seed`.
pub fn shuffle(
///
/// This is a Fisher-Yates-Durtstenfeld shuffle.
pub fn shuffle<T>(
seed: &[u8],
mut list: Vec<usize>)
-> Result<Vec<usize>, ShuffleErr>
mut list: Vec<T>)
-> Result<Vec<T>, ShuffleErr>
{
let mut rng = ShuffleRng::new(seed);
if list.len() > rng.rand_max as usize {