diff --git a/src/choose_gossip_peer_strategy.rs b/src/choose_gossip_peer_strategy.rs index 5642e006513404..dec6a0aee3f00d 100644 --- a/src/choose_gossip_peer_strategy.rs +++ b/src/choose_gossip_peer_strategy.rs @@ -1,5 +1,5 @@ use crdt::ReplicatedData; -use rand::distributions::{IndependentSample, Weighted, WeightedChoice}; +use rand::distributions::{Distribution, Weighted, WeightedChoice}; use rand::thread_rng; use result::{Error, Result}; use signature::PublicKey; @@ -37,26 +37,26 @@ impl<'a> ChooseGossipPeerStrategy for ChooseRandomPeerStrategy<'a> { } } -// This strategy uses rumors accumulated from the rest of the network to weight -// the importance of communicating with a particular validator based on cumulative network +// This strategy uses rumors accumulated from the rest of the network to weight +// the importance of communicating with a particular validator based on cumulative network // perceiption of the number of updates the validator has to offer. A validator is randomly // picked based on a weighted sample from the pool of viable choices. The "weight", w, of a // particular validator "v" is calculated as follows: -// -// w = [Sum for all i in I_v: (rumor_v(i) - observed(v)) * stake(i)] / +// +// w = [Sum for all i in I_v: (rumor_v(i) - observed(v)) * stake(i)] / // [Sum for all i in I_v: Sum(stake(i))] // // where I_v is the set of all validators that returned a rumor about the update_index of // validator "v", stake(i) is the size of the stake of validator "i", observed(v) is the -// observed update_index from the last direct communication validator "v", and +// observed update_index from the last direct communication validator "v", and // rumor_v(i) is the rumored update_index of validator "v" propagated by fellow validator "i". // This could be a problem if there are validators with large stakes lying about their -// observed updates. There could also be a problem in network partitions, or even just +// observed updates. There could also be a problem in network partitions, or even just // when certain validators are disproportionately active, where we hear more rumors about // certain clusters of nodes that then propagate more rumros about each other. Hopefully -// this can be resolved with a good baseline DEFAULT_WEIGHT, or by implementing lockout -// periods for very active validators in the future. +// this can be resolved with a good baseline DEFAULT_WEIGHT, or by implementing lockout +// periods for very active validators in the future. pub struct ChooseWeightedPeerStrategy<'a> { // The map of last directly observed update_index for each active validator. @@ -184,7 +184,7 @@ impl<'a> ChooseGossipPeerStrategy for ChooseWeightedPeerStrategy<'a> { } let mut rng = thread_rng(); - Ok(WeightedChoice::new(&mut weighted_peers).ind_sample(&mut rng)) + Ok(WeightedChoice::new(&mut weighted_peers).sample(&mut rng)) } } @@ -196,8 +196,8 @@ mod tests { use std; use std::collections::HashMap; - fn get_stake(id: PublicKey) -> f64 { - return 1.0; + fn get_stake(_id: PublicKey) -> f64 { + 1.0 } #[test] @@ -315,7 +315,7 @@ mod tests { remote.insert(key1, old_index); - for i in 0..num_peers { + for _i in 0..num_peers { let pk = KeyPair::new().pubkey(); rumors.insert(pk, old_index); } diff --git a/src/crdt.rs b/src/crdt.rs index cce92f017dd636..32c3383f5089b0 100644 --- a/src/crdt.rs +++ b/src/crdt.rs @@ -15,9 +15,7 @@ use bincode::{deserialize, serialize}; use byteorder::{LittleEndian, ReadBytesExt}; -use choose_gossip_peer_strategy::{ - ChooseGossipPeerStrategy, ChooseRandomPeerStrategy, ChooseWeightedPeerStrategy, -}; +use choose_gossip_peer_strategy::{ChooseGossipPeerStrategy, ChooseWeightedPeerStrategy}; use hash::Hash; use packet::{to_blob, Blob, BlobRecycler, SharedBlob, BLOB_SIZE}; use pnet_datalink as datalink; @@ -491,7 +489,7 @@ impl Crdt { } // TODO: fill in with real implmentation once staking is implemented - fn get_stake(id: PublicKey) -> f64 { + fn get_stake(_id: PublicKey) -> f64 { 1.0 } diff --git a/src/lib.rs b/src/lib.rs index 7f17a0f66f4383..da04911dee64a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ pub mod bank; pub mod banking_stage; pub mod blob_fetch_stage; pub mod budget; -mod choose_gossip_peer_strategy; +pub mod choose_gossip_peer_strategy; pub mod crdt; pub mod drone; pub mod entry;