Skip to content

Commit

Permalink
Refactor string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Dec 4, 2023
1 parent 33c6b05 commit 68e5e1c
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions yamux/src/connection/rtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,20 @@ impl Rtt {

let (sent_at, expected_nonce) = match inner.state {
RttState::Waiting { .. } => {
log::error!("received unexpected pong {}", received_nonce);
log::error!("received unexpected pong {received_nonce}");
return Action::Terminate(Frame::protocol_error());
}
RttState::AwaitingPong { sent_at, nonce } => (sent_at, nonce),
};

if received_nonce != expected_nonce {
log::error!(
"received pong with {} but expected {}",
received_nonce,
expected_nonce
);
log::error!("received pong with {received_nonce} but expected {expected_nonce}");
return Action::Terminate(Frame::protocol_error());
}

inner.rtt = Some(sent_at.elapsed());
log::debug!(
"received pong {received_nonce}, estimated round-trip-time {:?}",
inner.rtt.as_ref().expect("rtt just set")
);
let rtt = sent_at.elapsed();
inner.rtt = Some(rtt);
log::debug!("received pong {received_nonce}, estimated round-trip-time {rtt:?}");

inner.state = RttState::Waiting {
next: Instant::now() + PING_INTERVAL,
Expand Down

0 comments on commit 68e5e1c

Please sign in to comment.