mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-08 03:51:22 +00:00
Update shuffling comments
This commit is contained in:
parent
2763f7bc00
commit
6d4a3bba11
@ -1,2 +0,0 @@
|
|||||||
This module includes the fundamental shuffling function. It does not do the
|
|
||||||
full validator delegation amongst slots.
|
|
@ -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;
|
extern crate hashing;
|
||||||
|
|
||||||
mod rng;
|
mod rng;
|
||||||
@ -9,13 +13,16 @@ pub enum ShuffleErr {
|
|||||||
ExceedsListLength,
|
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
|
/// The final order of the shuffle is determined by successive hashes
|
||||||
/// of the supplied `seed`.
|
/// of the supplied `seed`.
|
||||||
pub fn shuffle(
|
///
|
||||||
|
/// This is a Fisher-Yates-Durtstenfeld shuffle.
|
||||||
|
pub fn shuffle<T>(
|
||||||
seed: &[u8],
|
seed: &[u8],
|
||||||
mut list: Vec<usize>)
|
mut list: Vec<T>)
|
||||||
-> Result<Vec<usize>, ShuffleErr>
|
-> Result<Vec<T>, ShuffleErr>
|
||||||
{
|
{
|
||||||
let mut rng = ShuffleRng::new(seed);
|
let mut rng = ShuffleRng::new(seed);
|
||||||
if list.len() > rng.rand_max as usize {
|
if list.len() > rng.rand_max as usize {
|
||||||
|
Loading…
Reference in New Issue
Block a user