aboutsummaryrefslogtreecommitdiff
path: root/src/peering/fullmesh.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/peering/fullmesh.rs')
-rw-r--r--src/peering/fullmesh.rs27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/peering/fullmesh.rs b/src/peering/fullmesh.rs
index e04beb6..4e9a78d 100644
--- a/src/peering/fullmesh.rs
+++ b/src/peering/fullmesh.rs
@@ -10,7 +10,6 @@ use serde::{Deserialize, Serialize};
use sodiumoxide::crypto::hash;
use sodiumoxide::crypto::sign::ed25519;
-use crate::conn::*;
use crate::message::*;
use crate::netapp::*;
use crate::proto::*;
@@ -162,10 +161,8 @@ impl FullMeshPeeringStrategy {
id: ping.id,
peer_list_hash: strat2.known_hosts.read().unwrap().hash,
};
- async move {
- debug!("Ping from {}", hex::encode(&from));
- Ok(ping_resp)
- }
+ debug!("Ping from {}", hex::encode(&from));
+ async move { ping_resp }
},
);
@@ -175,7 +172,7 @@ impl FullMeshPeeringStrategy {
strat2.handle_peer_list(&peer_list.list[..]);
let peer_list = KnownHosts::map_into_vec(&strat2.known_hosts.read().unwrap().list);
let resp = PeerListMessage { list: peer_list };
- async move { Ok(resp) }
+ async move { resp }
},
);
@@ -260,16 +257,6 @@ impl FullMeshPeeringStrategy {
}
async fn ping(self: Arc<Self>, id: ed25519::PublicKey) {
- let peer = {
- match self.netapp.client_conns.read().unwrap().get(&id) {
- None => {
- warn!("Should ping {}, but no connection", hex::encode(id));
- return;
- }
- Some(peer) => peer.clone(),
- }
- };
-
let peer_list_hash = self.known_hosts.read().unwrap().hash;
let ping_id = self.next_ping_id.fetch_add(1u64, atomic::Ordering::Relaxed);
let ping_time = Instant::now();
@@ -284,7 +271,7 @@ impl FullMeshPeeringStrategy {
hex::encode(id),
ping_time
);
- match peer.clone().request(ping_msg, prio::HIGH).await {
+ match self.netapp.request(&id, ping_msg, prio::HIGH).await {
Err(e) => warn!("Error pinging {}: {}", hex::encode(id), e),
Ok(ping_resp) => {
let resp_time = Instant::now();
@@ -304,16 +291,16 @@ impl FullMeshPeeringStrategy {
}
}
if ping_resp.peer_list_hash != peer_list_hash {
- self.exchange_peers(peer).await;
+ self.exchange_peers(&id).await;
}
}
}
}
- async fn exchange_peers(self: Arc<Self>, peer: Arc<ClientConn>) {
+ async fn exchange_peers(self: Arc<Self>, id: &ed25519::PublicKey) {
let peer_list = KnownHosts::map_into_vec(&self.known_hosts.read().unwrap().list);
let pex_message = PeerListMessage { list: peer_list };
- match peer.request(pex_message, prio::BACKGROUND).await {
+ match self.netapp.request(id, pex_message, prio::BACKGROUND).await {
Err(e) => warn!("Error doing peer exchange: {}", e),
Ok(resp) => {
self.handle_peer_list(&resp.list[..]);