diff --git a/eth2/fork_choice/src/lib.rs b/eth2/fork_choice/src/lib.rs index a947473f3..0d6969e89 100644 --- a/eth2/fork_choice/src/lib.rs +++ b/eth2/fork_choice/src/lib.rs @@ -22,8 +22,8 @@ extern crate types; pub mod bitwise_lmd_ghost; pub mod longest_chain; -pub mod slow_lmd_ghost; pub mod optimized_lmd_ghost; +pub mod slow_lmd_ghost; use db::stores::BeaconBlockAtSlotError; use db::DBError; @@ -31,8 +31,8 @@ use types::{BeaconBlock, ChainSpec, Hash256}; pub use bitwise_lmd_ghost::BitwiseLMDGhost; pub use longest_chain::LongestChain; -pub use slow_lmd_ghost::SlowLMDGhost; pub use optimized_lmd_ghost::OptimizedLMDGhost; +pub use slow_lmd_ghost::SlowLMDGhost; /// Defines the interface for Fork Choices. Each Fork choice will define their own data structures /// which can be built in block processing through the `add_block` and `add_attestation` functions. @@ -104,5 +104,5 @@ pub enum ForkChoiceAlgorithm { /// An optimised version of bitwise LMD-GHOST by Vitalik. BitwiseLMDGhost, /// An optimised implementation of LMD ghost. - OptimizedLMDGhost + OptimizedLMDGhost, } diff --git a/eth2/fork_choice/src/optimized_lmd_ghost.rs b/eth2/fork_choice/src/optimized_lmd_ghost.rs index e0074d4de..636ccdabc 100644 --- a/eth2/fork_choice/src/optimized_lmd_ghost.rs +++ b/eth2/fork_choice/src/optimized_lmd_ghost.rs @@ -7,8 +7,8 @@ use db::{ ClientDB, }; use log::{debug, trace}; -use std::collections::HashMap; use std::cmp::Ordering; +use std::collections::HashMap; use std::sync::Arc; use types::{ readers::BeaconBlockReader, validator_registry::get_active_validator_indices, BeaconBlock, @@ -202,12 +202,12 @@ where } // Iterate through hashmap to get child with maximum votes - let best_child = votes.iter().max_by(|(child1,v1), (child2, v2)| { - let mut result = v1.cmp(v2); + let best_child = votes.iter().max_by(|(child1, v1), (child2, v2)| { + let mut result = v1.cmp(v2); // If votes are equal, choose smaller hash to break ties deterministically if result == Ordering::Equal { - // Reverse so that max_by chooses smaller hash - result = child1.cmp(child2).reverse(); + // Reverse so that max_by chooses smaller hash + result = child1.cmp(child2).reverse(); } result }); diff --git a/eth2/fork_choice/tests/tests.rs b/eth2/fork_choice/tests/tests.rs index 1c8d92e0a..5fb963ea5 100644 --- a/eth2/fork_choice/tests/tests.rs +++ b/eth2/fork_choice/tests/tests.rs @@ -16,7 +16,9 @@ use bls::Signature; use db::stores::{BeaconBlockStore, BeaconStateStore}; use db::MemoryDB; // use env_logger::{Builder, Env}; -use fork_choice::{BitwiseLMDGhost, OptimizedLMDGhost, ForkChoice, ForkChoiceAlgorithm, LongestChain, SlowLMDGhost}; +use fork_choice::{ + BitwiseLMDGhost, ForkChoice, ForkChoiceAlgorithm, LongestChain, OptimizedLMDGhost, SlowLMDGhost, +}; use ssz::ssz_encode; use std::collections::HashMap; use std::sync::Arc;