Saved timed out peers as potential peers
All checks were successful
CI / Formatting (push) Successful in 30s

This commit is contained in:
Michael Bradley 2025-10-18 18:21:33 -04:00
parent 46f00e2047
commit 0f2248a2cb
Signed by: MichaelBradley
SSH key fingerprint: SHA256:BKO2eI2LPsCbQS3n3i5SdwZTAIV3F1lHezR07qP+Ob0
2 changed files with 15 additions and 5 deletions

View file

@ -104,7 +104,7 @@ pub struct PotentialPeerUI;
pub fn setup_potential_peer_ui(mut commands: Commands) { pub fn setup_potential_peer_ui(mut commands: Commands) {
commands commands
.spawn(( .spawn((
Text::new("Potential peers:"), Text::new("Potential peers:\n"),
Node { Node {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
bottom: Val::Px(5.0), bottom: Val::Px(5.0),

View file

@ -210,11 +210,23 @@ pub fn handle_peer_change(
} else { } else {
warn!("Peer {} doesn't exist (just added?)", change.peer); warn!("Peer {} doesn't exist (just added?)", change.peer);
} }
potential_peers.addresses.remove(&addr);
} }
// Peer deletion // Peer deletion
(Some(entity), None) => { (Some(entity), None) => {
commands.get_entity(*entity)?.despawn(); commands.get_entity(*entity)?.despawn();
peer_map.remove(&change.peer); if let Ok(peer) = peers.get(*entity) {
potential_peers.addresses.insert(peer.addr.into());
} else {
warn!(
"Peer {} could not be saved as a potential peer",
change.peer
)
}
peer_map.remove(&change.peer).ok_or(format!(
"Peer {} could not be removed from the peer map",
change.peer
))?;
} }
// Peer addition // Peer addition
(None, Some(addr)) => { (None, Some(addr)) => {
@ -230,13 +242,11 @@ pub fn handle_peer_change(
)) ))
.id(), .id(),
); );
potential_peers.addresses.remove(&addr);
} }
// Double peer deletion // Double peer deletion
(None, None) => warn!("Peer {} already deleted", change.peer), (None, None) => warn!("Peer {} already deleted", change.peer),
} }
if let Some(addr) = change.addr {
potential_peers.addresses.remove(&addr);
}
} }
Ok(()) Ok(())
} }