forked from lx/netapp
clippy & fmt
This commit is contained in:
parent
57327f10e2
commit
9b64c27da6
1 changed files with 12 additions and 11 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue