Extending peer timeout on peer message

This commit is contained in:
Dennis Schwerdel 2016-08-12 08:31:21 +02:00
parent 937c7b9f3b
commit 1da38f5205
1 changed files with 9 additions and 0 deletions

View File

@ -97,6 +97,13 @@ impl PeerList {
} }
} }
#[inline]
fn refresh(&mut self, addr: &SocketAddr) {
if let Some(&mut (ref mut timeout, _node_id, ref _alt_addrs)) = self.peers.get_mut(addr) {
*timeout = now()+self.timeout as Time;
}
}
#[inline] #[inline]
fn add_alt_addr(&mut self, node_id: NodeId, addr: SocketAddr) { fn add_alt_addr(&mut self, node_id: NodeId, addr: SocketAddr) {
if let Some(main_addr) = self.nodes.get(&node_id) { if let Some(main_addr) = self.nodes.get(&node_id) {
@ -512,6 +519,8 @@ impl<P: Protocol> GenericCloud<P> {
try!(self.connect(p)); try!(self.connect(p));
} }
} }
// Refresh peer
self.peers.refresh(&peer);
}, },
Message::Init(stage, node_id, ranges) => { Message::Init(stage, node_id, ranges) => {
// Avoid connecting to self // Avoid connecting to self