fix clippy on basalt code

This commit is contained in:
Alex 2021-10-12 13:28:57 +02:00
parent 74e661febe
commit 940750b5db
No known key found for this signature in database
GPG key ID: EDABF9711E244EB1

View file

@ -52,6 +52,7 @@ impl Peer {
fn cost(&self, seed: &Seed) -> Cost {
let mut hasher = hash::State::new();
hasher.update(&seed[..]);
let hasher = hasher;
let mut cost = [0u8; 40];
match self.addr {
@ -59,7 +60,7 @@ impl Peer {
let v4ip = v4addr.ip().octets();
for i in 0..4 {
let mut h = hasher.clone();
let mut h = hasher;
h.update(&v4ip[..i + 1]);
cost[i * 8..(i + 1) * 8].copy_from_slice(&h.finalize()[..8]);
}
@ -68,7 +69,7 @@ impl Peer {
let v6ip = v6addr.ip().octets();
for i in 0..4 {
let mut h = hasher.clone();
let mut h = hasher;
h.update(&v6ip[..i + 2]);
cost[i * 8..(i + 1) * 8].copy_from_slice(&h.finalize()[..8]);
}
@ -76,7 +77,7 @@ impl Peer {
}
{
let mut h5 = hasher.clone();
let mut h5 = hasher;
h5.update(&format!("{} {}", self.addr, hex::encode(self.id)).into_bytes()[..]);
cost[32..40].copy_from_slice(&h5.finalize()[..8]);
}
@ -115,8 +116,7 @@ impl BasaltView {
fn current_peers(&self) -> HashSet<Peer> {
self.slots
.iter()
.filter(|s| s.peer.is_some())
.map(|s| s.peer.unwrap().clone())
.filter_map(|s| s.peer)
.collect::<HashSet<_>>()
}
fn current_peers_vec(&self) -> Vec<Peer> {
@ -131,7 +131,7 @@ impl BasaltView {
.filter(|(_i, s)| s.peer.is_some())
.map(|(i, _s)| i)
.collect::<Vec<_>>();
if possibles.len() == 0 {
if possibles.is_empty() {
vec![]
} else {
let mut ret = vec![];
@ -290,7 +290,7 @@ impl Basalt {
let basalt2 = basalt.clone();
netapp.add_msg_handler::<PushMessage, _, _>(move |_from: NodeID, push_msg: PushMessage| {
basalt2.handle_peer_list(&push_msg.peers[..]);
async move { () }
async move { }
});
basalt