Skip to content

Commit

Permalink
Log the time duration for processing RPC requests
Browse files Browse the repository at this point in the history
  • Loading branch information
shesek committed Feb 24, 2024
1 parent 1708fc1 commit 626d7d3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/electrum/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream};
use std::sync::mpsc::{Sender, SyncSender, TrySendError};
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Instant;

use bitcoin::hashes::sha256d::Hash as Sha256dHash;
use crypto::digest::Digest;
Expand Down Expand Up @@ -554,6 +555,7 @@ impl Connection {
})
);

let start_time = Instant::now();
let reply = self.handle_command(method, params, id)?;

conditionally_log_rpc_event!(
Expand All @@ -562,6 +564,7 @@ impl Connection {
"event": "rpc response",
"method": method,
"payload_size": reply.to_string().as_bytes().len(),
"duration_ms": start_time.elapsed().as_millis(),
"id": id,
})
);
Expand Down

0 comments on commit 626d7d3

Please sign in to comment.