diff --git a/lighthouse/main.rs b/lighthouse/main.rs index 867a3ed00..0a9f35288 100644 --- a/lighthouse/main.rs +++ b/lighthouse/main.rs @@ -8,13 +8,12 @@ extern crate futures; pub mod db; pub mod client; -pub mod shuffling; pub mod state; pub mod sync; pub mod utils; pub mod config; -use std::path::PathBuf; +use std::path::PathBuf; use slog::Drain; use clap::{ Arg, App }; @@ -59,9 +58,9 @@ fn main() { return; } } - + // Log configuration - info!(log, ""; + info!(log, ""; "data_dir" => &config.data_dir.to_str(), "port" => &config.p2p_listen_port); diff --git a/lighthouse/state/transition/mod.rs b/lighthouse/state/transition/mod.rs index ef7b4e778..40dd10b8e 100644 --- a/lighthouse/state/transition/mod.rs +++ b/lighthouse/state/transition/mod.rs @@ -9,3 +9,5 @@ pub enum TransitionError { InvalidInput(String), } + + diff --git a/lighthouse/shuffling/mod.rs b/lighthouse/state/transition/shuffling/mod.rs similarity index 96% rename from lighthouse/shuffling/mod.rs rename to lighthouse/state/transition/shuffling/mod.rs index d706fad2c..432f38ff4 100644 --- a/lighthouse/shuffling/mod.rs +++ b/lighthouse/state/transition/shuffling/mod.rs @@ -9,18 +9,18 @@ pub enum ShuffleErr { ExceedsListLength, } -/// Performs a deterministic, in-place shuffle of a vector of bytes. +/// Performs a deterministic, in-place shuffle of a vector of bytes. /// The final order of the shuffle is determined by successive hashes /// of the supplied `seed`. pub fn shuffle( seed: &[u8], - mut list: Vec) + mut list: Vec) -> Result, ShuffleErr> { let mut rng = ShuffleRng::new(seed); if list.len() > rng.rand_max as usize { return Err(ShuffleErr::ExceedsListLength); - } + } for i in 0..(list.len() - 1) { let n = list.len() - i; let j = rng.rand_range(n as u32) as usize + i; diff --git a/lighthouse/shuffling/rng.rs b/lighthouse/state/transition/shuffling/rng.rs similarity index 99% rename from lighthouse/shuffling/rng.rs rename to lighthouse/state/transition/shuffling/rng.rs index 7564b2ab1..224e9130f 100644 --- a/lighthouse/shuffling/rng.rs +++ b/lighthouse/state/transition/shuffling/rng.rs @@ -94,22 +94,22 @@ mod tests { &[0, 1, 1], 0); assert_eq!(x, 257); - + x = int_from_byte_slice( &[1, 1, 1], 0); assert_eq!(x, 65793); - + x = int_from_byte_slice( &[255, 1, 1], 0); assert_eq!(x, 16711937); - + x = int_from_byte_slice( &[255, 255, 255], 0); assert_eq!(x, 16777215); - + x = int_from_byte_slice( &[0x8f, 0xbb, 0xc7], 0);