Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(iroh-net): Remove PathState::recent_pong() #2745

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions iroh-net/src/magicsock/node_map/node_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ impl NodeState {
.udp_paths
.paths
.iter()
.map(|(addr, endpoint_state)| DirectAddrInfo {
.map(|(addr, path_state)| DirectAddrInfo {
addr: SocketAddr::from(*addr),
latency: endpoint_state.recent_pong().map(|pong| pong.latency),
last_control: endpoint_state.last_control_msg(now),
last_payload: endpoint_state
latency: path_state.recent_pong.as_ref().map(|pong| pong.latency),
last_control: path_state.last_control_msg(now),
last_payload: path_state
.last_payload_msg
.as_ref()
.map(|instant| now.duration_since(*instant)),
last_alive: endpoint_state
last_alive: path_state
.last_alive()
.map(|instant| now.duration_since(instant)),
})
Expand Down
11 changes: 4 additions & 7 deletions iroh-net/src/magicsock/node_map/path_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ impl PathState {
/// - When the last payload transmission occurred.
/// - when the last ping from them was received.
pub(super) fn last_alive(&self) -> Option<Instant> {
self.recent_pong()
self.recent_pong
.as_ref()
.map(|pong| &pong.pong_at)
.into_iter()
.chain(self.last_payload_msg.as_ref())
Expand All @@ -173,7 +174,8 @@ impl PathState {
pub(super) fn last_control_msg(&self, now: Instant) -> Option<(Duration, ControlMsg)> {
// get every control message and assign it its kind
let last_pong = self
.recent_pong()
.recent_pong
.as_ref()
.map(|pong| (pong.pong_at, ControlMsg::Pong));
let last_call_me_maybe = self
.call_me_maybe_time
Expand All @@ -191,11 +193,6 @@ impl PathState {
.map(|(instant, kind)| (now.duration_since(instant), kind))
}

/// Returns the most recent pong if available.
pub(super) fn recent_pong(&self) -> Option<&PongReply> {
self.recent_pong.as_ref()
}

/// Returns the latency from the most recent pong, if available.
pub(super) fn latency(&self) -> Option<Duration> {
self.recent_pong.as_ref().map(|p| p.latency)
Expand Down
4 changes: 2 additions & 2 deletions iroh-net/src/magicsock/node_map/udp_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ impl NodeUdpPaths {
let best_latency = best_pong
.map(|p: &PongReply| p.latency)
.unwrap_or(MAX_LATENCY);
match state.recent_pong() {
match state.recent_pong {
// This pong is better if it has a lower latency, or if it has the same
// latency but on an IPv6 path.
Some(pong)
Some(ref pong)
if pong.latency < best_latency
|| (pong.latency == best_latency && ipp.ip().is_ipv6()) =>
{
Expand Down
Loading