Fix docs and clippy

This commit is contained in:
Floris Bruynooghe
2025-11-27 19:17:41 +01:00
committed by GitHub
parent 5bd31b72f8
commit b0c01088a6
2 changed files with 9 additions and 5 deletions
+3 -3
View File
@@ -4501,7 +4501,7 @@ impl Connection {
warn!(?addr, "server sent ilegal ADD_ADDRESS frame");
}
match client_state.add_remote_address(addr.clone()) {
match client_state.add_remote_address(addr) {
Ok(maybe_added) => {
if let Some(added) = maybe_added {
self.events.push_back(Event::NatTraversal(
@@ -4527,7 +4527,7 @@ impl Connection {
));
};
if let Some(removed_addr) = client_state.remove_remote_address(addr.clone()) {
if let Some(removed_addr) = client_state.remove_remote_address(addr) {
self.events
.push_back(Event::NatTraversal(iroh_hp::Event::AddressRemoved(
removed_addr,
@@ -5915,7 +5915,7 @@ impl Connection {
/// This is calculated as minimum between the local and remote's maximums when multipath is
/// enabled, or `None` when disabled.
///
/// For data that's received, we should use [`self.local_max_path_id`] instead.
/// For data that's received, we should use [`Self::local_max_path_id`] instead.
/// The reasoning is that the remote might already have updated to its own newer
/// [`Self::max_path_id`] after sending out a `MAX_PATH_ID` frame, but it got re-ordered.
fn max_path_id(&self) -> Option<PathId> {
+6 -2
View File
@@ -1,3 +1,5 @@
//! iroh NAT Traversal
use std::{
collections::hash_map::Entry,
net::{IpAddr, SocketAddr},
@@ -56,10 +58,12 @@ pub(crate) struct RandDataNeeded {
pub(crate) is_new_round: bool,
}
// TODO(@divma): unclear to me what these events are useful for\
/// Event emitted when the client receives ADD_ADDRESS or REMOVE_ADDRESS frames.
#[derive(Debug, Clone)]
pub enum Event {
/// An ADD_ADDRESS frame was received.
AddressAdded(SocketAddr),
/// A REMOVE_ADDRESS frame was received.
AddressRemoved(SocketAddr),
}
@@ -207,7 +211,7 @@ impl State {
return Err(Error::NotEnoughAddresses);
}
let prev_round_path_ids = std::mem::replace(&mut self.round_path_ids, Default::default());
let prev_round_path_ids = std::mem::take(&mut self.round_path_ids);
self.round = self.round.saturating_add(1u8);
Ok(NatTraversalRound {