Skip to content

Commit

Permalink
timer tick separately for each rpc req
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Oct 15, 2024
1 parent 4b66d0a commit b8f4524
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/electrum/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,20 +541,19 @@ impl Connection {
let empty_params = json!([]);
loop {
let msg = receiver.recv().chain_err(|| "channel closed")?;
let start_time = Instant::now();
trace!("RPC {:?}", msg);
match msg {
Message::Request(line) => {
let cmd: Value = from_str(&line).chain_err(|| "invalid JSON format")?;
if let Value::Array(arr) = cmd {
let mut result = Vec::with_capacity(arr.len());
for el in arr {
let reply = self.handle_value(el, &empty_params, start_time)?;
let reply = self.handle_value(el, &empty_params)?;
result.push(reply)
}
self.send_values(&[Value::Array(result)])?
} else {
let reply = self.handle_value(cmd, &empty_params, start_time)?;
let reply = self.handle_value(cmd, &empty_params)?;
self.send_values(&[reply])?
}
}
Expand All @@ -569,12 +568,8 @@ impl Connection {
}
}

fn handle_value(
&mut self,
cmd: Value,
empty_params: &Value,
start_time: Instant,
) -> Result<Value> {
fn handle_value(&mut self, cmd: Value, empty_params: &Value) -> Result<Value> {
let start_time = Instant::now();
Ok(
match (
cmd.get("method"),
Expand Down

0 comments on commit b8f4524

Please sign in to comment.