From 8a0bfa0ff6bc6b79c91c8e635dd00c2f687ec401 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 14 Oct 2021 14:54:48 +0200 Subject: Change call() to take a ref to the message to be sent Handlers also receive a ref --- src/peering/basalt.rs | 8 ++++---- src/peering/fullmesh.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/peering') diff --git a/src/peering/basalt.rs b/src/peering/basalt.rs index cdb0605..7f77995 100644 --- a/src/peering/basalt.rs +++ b/src/peering/basalt.rs @@ -331,7 +331,7 @@ impl Basalt { async fn do_pull(self: Arc, peer: NodeID) { match self .pull_endpoint - .call(&peer, PullMessage {}, PRIO_NORMAL) + .call(&peer, &PullMessage {}, PRIO_NORMAL) .await { Ok(resp) => { @@ -346,7 +346,7 @@ impl Basalt { async fn do_push(self: Arc, peer: NodeID) { let push_msg = self.make_push_message(); - match self.push_endpoint.call(&peer, push_msg, PRIO_NORMAL).await { + match self.push_endpoint.call(&peer, &push_msg, PRIO_NORMAL).await { Ok(_) => { trace!("KYEV PEXo {}", hex::encode(peer)); } @@ -468,14 +468,14 @@ impl Basalt { #[async_trait] impl EndpointHandler for Basalt { - async fn handle(self: &Arc, _pullmsg: PullMessage, _from: NodeID) -> PushMessage { + async fn handle(self: &Arc, _pullmsg: &PullMessage, _from: NodeID) -> PushMessage { self.make_push_message() } } #[async_trait] impl EndpointHandler for Basalt { - async fn handle(self: &Arc, pushmsg: PushMessage, _from: NodeID) { + async fn handle(self: &Arc, pushmsg: &PushMessage, _from: NodeID) { self.handle_peer_list(&pushmsg.peers[..]); } } diff --git a/src/peering/fullmesh.rs b/src/peering/fullmesh.rs index ea753e1..5f17718 100644 --- a/src/peering/fullmesh.rs +++ b/src/peering/fullmesh.rs @@ -329,7 +329,7 @@ impl FullMeshPeeringStrategy { hex::encode(id), ping_time ); - match self.ping_endpoint.call(&id, ping_msg, PRIO_HIGH).await { + match self.ping_endpoint.call(&id, &ping_msg, PRIO_HIGH).await { Err(e) => warn!("Error pinging {}: {}", hex::encode(id), e), Ok(ping_resp) => { let resp_time = Instant::now(); @@ -361,7 +361,7 @@ impl FullMeshPeeringStrategy { let pex_message = PeerListMessage { list: peer_list }; match self .peer_list_endpoint - .call(id, pex_message, PRIO_BACKGROUND) + .call(id, &pex_message, PRIO_BACKGROUND) .await { Err(e) => warn!("Error doing peer exchange: {}", e), @@ -451,7 +451,7 @@ impl FullMeshPeeringStrategy { #[async_trait] impl EndpointHandler for FullMeshPeeringStrategy { - async fn handle(self: &Arc, ping: PingMessage, from: NodeID) -> PingMessage { + async fn handle(self: &Arc, ping: &PingMessage, from: NodeID) -> PingMessage { let ping_resp = PingMessage { id: ping.id, peer_list_hash: self.known_hosts.read().unwrap().hash, @@ -465,7 +465,7 @@ impl EndpointHandler for FullMeshPeeringStrategy { impl EndpointHandler for FullMeshPeeringStrategy { async fn handle( self: &Arc, - peer_list: PeerListMessage, + peer_list: &PeerListMessage, _from: NodeID, ) -> PeerListMessage { self.handle_peer_list(&peer_list.list[..]); -- cgit v1.2.3