Saved timed out peers as potential peers
All checks were successful
CI / Formatting (push) Successful in 30s
All checks were successful
CI / Formatting (push) Successful in 30s
This commit is contained in:
parent
46f00e2047
commit
0f2248a2cb
2 changed files with 15 additions and 5 deletions
|
|
@ -104,7 +104,7 @@ pub struct PotentialPeerUI;
|
|||
pub fn setup_potential_peer_ui(mut commands: Commands) {
|
||||
commands
|
||||
.spawn((
|
||||
Text::new("Potential peers:"),
|
||||
Text::new("Potential peers:\n"),
|
||||
Node {
|
||||
position_type: PositionType::Absolute,
|
||||
bottom: Val::Px(5.0),
|
||||
|
|
|
|||
|
|
@ -210,11 +210,23 @@ pub fn handle_peer_change(
|
|||
} else {
|
||||
warn!("Peer {} doesn't exist (just added?)", change.peer);
|
||||
}
|
||||
potential_peers.addresses.remove(&addr);
|
||||
}
|
||||
// Peer deletion
|
||||
(Some(entity), None) => {
|
||||
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
|
||||
(None, Some(addr)) => {
|
||||
|
|
@ -230,13 +242,11 @@ pub fn handle_peer_change(
|
|||
))
|
||||
.id(),
|
||||
);
|
||||
potential_peers.addresses.remove(&addr);
|
||||
}
|
||||
// Double peer deletion
|
||||
(None, None) => warn!("Peer {} already deleted", change.peer),
|
||||
}
|
||||
if let Some(addr) = change.addr {
|
||||
potential_peers.addresses.remove(&addr);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue