From 6d4a3bba11ce0f9b2feb5ace47986e4c8fe102ad Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 3 Oct 2018 13:43:46 +1000 Subject: [PATCH] Update shuffling comments --- beacon_chain/utils/shuffling/README.md | 2 -- beacon_chain/utils/shuffling/src/lib.rs | 15 +++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) delete mode 100644 beacon_chain/utils/shuffling/README.md diff --git a/beacon_chain/utils/shuffling/README.md b/beacon_chain/utils/shuffling/README.md deleted file mode 100644 index b0f4f5245..000000000 --- a/beacon_chain/utils/shuffling/README.md +++ /dev/null @@ -1,2 +0,0 @@ -This module includes the fundamental shuffling function. It does not do the -full validator delegation amongst slots. diff --git a/beacon_chain/utils/shuffling/src/lib.rs b/beacon_chain/utils/shuffling/src/lib.rs index b99d400a1..7acb7408a 100644 --- a/beacon_chain/utils/shuffling/src/lib.rs +++ b/beacon_chain/utils/shuffling/src/lib.rs @@ -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( seed: &[u8], - mut list: Vec) - -> Result, ShuffleErr> + mut list: Vec) + -> Result, ShuffleErr> { let mut rng = ShuffleRng::new(seed); if list.len() > rng.rand_max as usize {