From e99b8dc5a39601a6d730cf214c5cbf3034fb95ab Mon Sep 17 00:00:00 2001 From: aggstam Date: Sat, 10 Dec 2022 02:27:55 +0200 Subject: [PATCH] rpc/client: minor cleanup --- src/rpc/client.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rpc/client.rs b/src/rpc/client.rs index 9985cd489..f1b30729c 100644 --- a/src/rpc/client.rs +++ b/src/rpc/client.rs @@ -262,12 +262,10 @@ impl RpcClient { // If data is incomplete, this will fail, therefore, // we re-execute read and write after previous read in the buffer, // and repeat until the data in buffer can be converted. - let mut total = 0; let mut n = 0; loop { - n = timeout(read_timeout, async { stream.read(&mut buf[n..]).await }).await?; - total += n; - match serde_json::from_slice(&buf[0..total]) { + n += timeout(read_timeout, async { stream.read(&mut buf[n..]).await }).await?; + match serde_json::from_slice(&buf[0..n]) { Ok(reply) => { result_send.send(reply).await?; break