diff options
-rw-r--r-- | examples/basalt.rs | 4 | ||||
-rw-r--r-- | src/client.rs | 4 | ||||
-rw-r--r-- | src/endpoint.rs | 8 | ||||
-rw-r--r-- | src/netapp.rs | 4 | ||||
-rw-r--r-- | src/peering/basalt.rs | 8 | ||||
-rw-r--r-- | src/peering/fullmesh.rs | 8 |
6 files changed, 18 insertions, 18 deletions
diff --git a/examples/basalt.rs b/examples/basalt.rs index 752583d..5628056 100644 --- a/examples/basalt.rs +++ b/examples/basalt.rs @@ -145,7 +145,7 @@ impl Example { tokio::spawn(async move { match self2 .example_endpoint - .call(&p, ExampleMessage { example_field: 42 }, PRIO_NORMAL) + .call(&p, &ExampleMessage { example_field: 42 }, PRIO_NORMAL) .await { Ok(resp) => debug!("Got example response: {:?}", resp), @@ -159,7 +159,7 @@ impl Example { #[async_trait] impl EndpointHandler<ExampleMessage> for Example { - async fn handle(self: &Arc<Self>, msg: ExampleMessage, _from: NodeID) -> ExampleResponse { + async fn handle(self: &Arc<Self>, msg: &ExampleMessage, _from: NodeID) -> ExampleResponse { debug!("Got example message: {:?}, sending example response", msg); ExampleResponse { example_field: false, diff --git a/src/client.rs b/src/client.rs index ffa6893..ca1bcf9 100644 --- a/src/client.rs +++ b/src/client.rs @@ -112,7 +112,7 @@ impl ClientConn { pub(crate) async fn call<T>( self: Arc<Self>, - rq: T, + rq: &T, path: &str, prio: RequestPriority, ) -> Result<<T as Message>::Response, Error> @@ -127,7 +127,7 @@ impl ClientConn { let mut bytes = vec![prio, path.as_bytes().len() as u8]; bytes.extend_from_slice(path.as_bytes()); - bytes.extend_from_slice(&rmp_to_vec_all_named(&rq)?[..]); + bytes.extend_from_slice(&rmp_to_vec_all_named(rq)?[..]); let (resp_send, resp_recv) = oneshot::channel(); let old = self.inflight.lock().unwrap().insert(id, resp_send); diff --git a/src/endpoint.rs b/src/endpoint.rs index adb3532..77d7468 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -26,7 +26,7 @@ pub trait EndpointHandler<M>: Send + Sync where M: Message, { - async fn handle(self: &Arc<Self>, m: M, from: NodeID) -> M::Response; + async fn handle(self: &Arc<Self>, m: &M, from: NodeID) -> M::Response; } /// If one simply wants to use an endpoint in a client fashion, @@ -35,7 +35,7 @@ where /// it will panic if it is ever made to handle request. #[async_trait] impl<M: Message + 'static> EndpointHandler<M> for () { - async fn handle(self: &Arc<()>, _m: M, _from: NodeID) -> M::Response { + async fn handle(self: &Arc<()>, _m: &M, _from: NodeID) -> M::Response { panic!("This endpoint should not have a local handler."); } } @@ -86,7 +86,7 @@ where pub async fn call( &self, target: &NodeID, - req: M, + req: &M, prio: RequestPriority, ) -> Result<<M as Message>::Response, Error> { if *target == self.netapp.id { @@ -141,7 +141,7 @@ where None => Err(Error::NoHandler), Some(h) => { let req = rmp_serde::decode::from_read_ref::<_, M>(buf)?; - let res = h.handle(req, from).await; + let res = h.handle(&req, from).await; let res_bytes = rmp_to_vec_all_named(&res)?; Ok(res_bytes) } diff --git a/src/netapp.rs b/src/netapp.rs index 7fe1e71..a7a3acf 100644 --- a/src/netapp.rs +++ b/src/netapp.rs @@ -366,7 +366,7 @@ impl NetApp { hello_endpoint .call( &conn.peer_id, - HelloMessage { + &HelloMessage { server_addr, server_port, }, @@ -401,7 +401,7 @@ impl NetApp { #[async_trait] impl EndpointHandler<HelloMessage> for NetApp { - async fn handle(self: &Arc<Self>, msg: HelloMessage, from: NodeID) { + async fn handle(self: &Arc<Self>, msg: &HelloMessage, from: NodeID) { if let Some(h) = self.on_connected_handler.load().as_ref() { if let Some(c) = self.server_conns.read().unwrap().get(&from) { let remote_ip = msg.server_addr.unwrap_or_else(|| c.remote_addr.ip()); 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<Self>, 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<Self>, 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<PullMessage> for Basalt { - async fn handle(self: &Arc<Self>, _pullmsg: PullMessage, _from: NodeID) -> PushMessage { + async fn handle(self: &Arc<Self>, _pullmsg: &PullMessage, _from: NodeID) -> PushMessage { self.make_push_message() } } #[async_trait] impl EndpointHandler<PushMessage> for Basalt { - async fn handle(self: &Arc<Self>, pushmsg: PushMessage, _from: NodeID) { + async fn handle(self: &Arc<Self>, 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<PingMessage> for FullMeshPeeringStrategy { - async fn handle(self: &Arc<Self>, ping: PingMessage, from: NodeID) -> PingMessage { + async fn handle(self: &Arc<Self>, 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<PingMessage> for FullMeshPeeringStrategy { impl EndpointHandler<PeerListMessage> for FullMeshPeeringStrategy { async fn handle( self: &Arc<Self>, - peer_list: PeerListMessage, + peer_list: &PeerListMessage, _from: NodeID, ) -> PeerListMessage { self.handle_peer_list(&peer_list.list[..]); |