Reconnecting to lost peers when receiving from them or sending to them

This commit is contained in:
Dennis Schwerdel 2016-06-26 19:21:26 +02:00
parent d7b930982d
commit ab7c033383
2 changed files with 10 additions and 4 deletions

View File

@ -6,7 +6,10 @@ This project follows [semantic versioning](http://semver.org).
- [changed] Updated dependencies
- [changed] Turned some clippy warnings off
- [changed] Cross-compiling for ARMv7
- [changed] Cross-compiling for ARM
- [removed] Removed Address remove code for prefix table
- [fixed] Reconnecting to lost peers when receiving from them or sending to them
- [fixed] Sending peer list more often to prevent timeouts
### v0.6.0 (2016-06-02)

View File

@ -362,11 +362,11 @@ impl<P: Protocol> GenericCloud<P> {
match self.table.lookup(&dst) {
Some(addr) => {
debug!("Found destination for {} => {}", dst, addr);
if self.peers.contains_addr(&addr) {
try!(self.send_msg(addr, &mut Message::Data(payload, start, end)))
} else {
try!(self.send_msg(addr, &mut Message::Data(payload, start, end)));
if !self.peers.contains_addr(&addr) {
warn!("Destination for {} not found in peers: {}", dst, addr);
self.table.remove(&dst);
try!(self.connect(&addr));
}
},
None => {
@ -406,6 +406,9 @@ impl<P: Protocol> GenericCloud<P> {
}
},
Message::Peers(peers) => {
if !self.peers.contains_addr(&peer) {
try!(self.connect(&peer));
}
for p in &peers {
if ! self.peers.contains_addr(p) && ! self.blacklist_peers.contains(p) {
try!(self.connect(p));