Skip to content

Commit

Permalink
Inform peers of ENR update
Browse files Browse the repository at this point in the history
  • Loading branch information
AgeManning committed Oct 28, 2024
1 parent 8cb608e commit 54cb41a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,17 @@ impl Service {
}
}
connectivity_timeout = self.connectivity_state.poll() => {
match connectivity_timeout {
let updated_enr = match connectivity_timeout {
TimerFailure::V4 => {
// We have not received enough incoming connections in the required
// time. Remove our ENR advertisement.
info!(ip_version="v4", next_attempt_in=%DURATION_UNTIL_NEXT_CONNECTIVITY_ATTEMPT.as_secs(), "UDP Socket removed from ENR");
if let Err(error) = self.local_enr.write().remove_udp_socket(&self.enr_key.read()) {
error!(?error, "Failed to update the ENR");
false
} else {
// ENR was updated
true
}
}
TimerFailure::V6 => {
Expand All @@ -482,8 +486,16 @@ impl Service {
info!(ip_version="v6", next_attempt_in=%DURATION_UNTIL_NEXT_CONNECTIVITY_ATTEMPT.as_secs(), "UDP Socket removed from ENR");
if let Err(error) = self.local_enr.write().remove_udp6_socket(&self.enr_key.read()) {
error!(?error, "Failed to update the ENR");
false
} else {
// ENR was updated
true
}
}
};
if updated_enr {
// Inform our known peers of our updated ENR
self.ping_connected_peers();
}
}
}
Expand Down

0 comments on commit 54cb41a

Please sign in to comment.