clippy & fmt

This commit is contained in:
Alex 2021-10-22 15:20:07 +02:00
parent 57327f10e2
commit 9b64c27da6
No known key found for this signature in database
GPG key ID: EDABF9711E244EB1

View file

@ -1,4 +1,4 @@
use std::collections::{HashMap, VecDeque};
use std::collections::{hash_map::Entry::Vacant, HashMap, VecDeque};
use std::net::SocketAddr;
use std::sync::atomic::{self, AtomicU64};
use std::sync::{Arc, RwLock};
@ -432,10 +432,8 @@ impl FullMeshPeeringStrategy {
fn on_connected(self: Arc<Self>, id: NodeID, addr: SocketAddr, is_incoming: bool) {
if is_incoming {
let mut known_hosts = self.known_hosts.write().unwrap();
if !known_hosts.list.contains_key(&id) {
known_hosts
.list
.insert(id, self.new_peer(&id, addr));
if let Vacant(entry) = known_hosts.list.entry(id) {
entry.insert(self.new_peer(&id, addr));
known_hosts.update_hash();
self.update_public_peer_list(&known_hosts);
}
@ -446,12 +444,15 @@ impl FullMeshPeeringStrategy {
host.state = PeerConnState::Connected;
host.addr = addr;
} else {
known_hosts.list.insert(id, PeerInfoInternal{
state: PeerConnState::Connected,
addr,
last_seen: None,
ping: VecDeque::new(),
});
known_hosts.list.insert(
id,
PeerInfoInternal {
state: PeerConnState::Connected,
addr,
last_seen: None,
ping: VecDeque::new(),
},
);
}
known_hosts.update_hash();
self.update_public_peer_list(&known_hosts);