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