From 726e90a5dc21e98313d8ab687772d90862361aac Mon Sep 17 00:00:00 2001 From: Mariusz Reichert Date: Wed, 20 Mar 2024 14:53:40 +0100 Subject: [PATCH] Moving duration calculation after replies are sent --- src/electrum/server.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/electrum/server.rs b/src/electrum/server.rs index 811cf0138..c424dfeb0 100644 --- a/src/electrum/server.rs +++ b/src/electrum/server.rs @@ -557,19 +557,21 @@ impl Connection { ); let reply = self.handle_command(method, params, id)?; + let reply_size = reply.to_string().as_bytes().len(); + let send_result = self.send_values(&[reply]); conditionally_log_rpc_event!( self, json!({ "event": "rpc response", "method": method, - "payload_size": reply.to_string().as_bytes().len(), + "payload_size": reply_size, "duration_micros": start_time.elapsed().as_micros(), "id": id, }) ); - self.send_values(&[reply])? + send_result? } _ => { bail!("invalid command: {}", cmd)