aboutsummaryrefslogtreecommitdiff
path: root/src/peering
diff options
context:
space:
mode:
Diffstat (limited to 'src/peering')
-rw-r--r--src/peering/fullmesh.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/peering/fullmesh.rs b/src/peering/fullmesh.rs
index 9b55180..b0bbe45 100644
--- a/src/peering/fullmesh.rs
+++ b/src/peering/fullmesh.rs
@@ -103,7 +103,7 @@ impl KnownHosts {
let mut list = Vec::with_capacity(input.len());
for (id, peer) in input.iter() {
if peer.state == PeerConnState::Connected || peer.state == PeerConnState::Ourself {
- list.push((id.clone(), peer.addr));
+ list.push((*id, peer.addr));
}
}
list
@@ -134,7 +134,7 @@ impl FullMeshPeeringStrategy {
known_hosts.list.insert(
id,
PeerInfo {
- addr: addr,
+ addr,
state: PeerConnState::Waiting(0, Instant::now()),
last_seen: None,
ping: VecDeque::new(),
@@ -201,12 +201,12 @@ impl FullMeshPeeringStrategy {
Some(t) => Instant::now() - t > PING_INTERVAL,
};
if must_ping {
- to_ping.push(id.clone());
+ to_ping.push(*id);
}
}
PeerConnState::Waiting(_, t) => {
if Instant::now() >= t {
- to_retry.push(id.clone());
+ to_retry.push(*id);
}
}
_ => (),
@@ -234,7 +234,7 @@ impl FullMeshPeeringStrategy {
i + 1
);
h.state = PeerConnState::Trying(i);
- tokio::spawn(self.clone().try_connect(id, h.addr.clone()));
+ tokio::spawn(self.clone().try_connect(id, h.addr));
}
}
}
@@ -307,7 +307,7 @@ impl FullMeshPeeringStrategy {
}
async fn try_connect(self: Arc<Self>, id: NodeID, addr: SocketAddr) {
- let conn_result = self.netapp.clone().try_connect(addr, id.clone()).await;
+ let conn_result = self.netapp.clone().try_connect(addr, id).await;
if let Err(e) = conn_result {
warn!("Error connecting to {}: {}", hex::encode(id), e);
let mut known_hosts = self.known_hosts.write().unwrap();
@@ -362,9 +362,9 @@ impl FullMeshPeeringStrategy {
for (id, info) in known_hosts.list.iter() {
let mut pings = info.ping.iter().cloned().collect::<Vec<_>>();
pings.sort();
- if pings.len() > 0 {
+ if !pings.is_empty() {
ret.push(PeerInfoPub {
- id: id.clone(),
+ id: *id,
addr: info.addr,
state: info.state,
last_seen: info.last_seen,
@@ -379,7 +379,7 @@ impl FullMeshPeeringStrategy {
});
} else {
ret.push(PeerInfoPub {
- id: id.clone(),
+ id: *id,
addr: info.addr,
state: info.state,
last_seen: info.last_seen,