Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
fix(comm): ignore connection loss
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoga07 authored and lionel-faber committed Jun 4, 2021
1 parent b2e159e commit 693f61c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 85 deletions.
55 changes: 26 additions & 29 deletions src/routing/core/connectivity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,32 @@ impl Core {
}
}

fn complain_connectivity(&self, name: XorName) -> Result<Vec<Command>> {
pub fn handle_connection_lost(&self, addr: SocketAddr) -> Result<Vec<Command>> {
if let Some(peer) = self.section.find_joined_member_by_addr(&addr) {
debug!(
"Possible connection loss detected with known peer {:?}",
peer
)
} else if let Some(end_user) = self.get_enduser_by_addr(&addr) {
debug!(
"Possible connection loss detected with known client {:?}",
end_user
)
} else {
debug!("Possible connection loss detected with addr: {:?}", addr);
}
Ok(vec![])
}

pub fn handle_peer_lost(&self, addr: &SocketAddr) -> Result<Vec<Command>> {
let name = if let Some(peer) = self.section.find_joined_member_by_addr(addr) {
debug!("Lost known peer {}", peer);
*peer.name()
} else {
trace!("Lost unknown peer {}", addr);
return Ok(vec![]);
};

if !self.is_elder() {
// When self is not an elder, then the peer has to be an elder, and we shall complaint
// the lost to other elders.
Expand Down Expand Up @@ -159,34 +184,6 @@ impl Core {
self.propose_offline(name)
}

pub fn handle_connection_lost(&self, addr: SocketAddr) -> Result<Vec<Command>> {
let name = if let Some(peer) = self.section.find_joined_member_by_addr(&addr) {
debug!("Lost connection to known peer {}", peer);
*peer.name()
} else {
if let Some(end_user) = self.get_enduser_by_addr(&addr) {
debug!("Lost connection to client {:?}", end_user);
} else {
debug!("Lost connection to unknown peer {}", addr);
}
return Ok(vec![]);
};

self.complain_connectivity(name)
}

pub fn handle_peer_lost(&self, addr: &SocketAddr) -> Result<Vec<Command>> {
let name = if let Some(peer) = self.section.find_joined_member_by_addr(addr) {
debug!("Lost known peer {}", peer);
*peer.name()
} else {
trace!("Lost unknown peer {}", addr);
return Ok(vec![]);
};

self.complain_connectivity(name)
}

pub fn propose_offline(&self, name: XorName) -> Result<Vec<Command>> {
self.cast_offline_proposals(&iter::once(name).collect())
}
Expand Down
56 changes: 0 additions & 56 deletions tests/drop.rs

This file was deleted.

0 comments on commit 693f61c

Please sign in to comment.