Extending peer timeout on peer message

pull/11/merge
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]
fn add_alt_addr(&mut self, node_id: NodeId, addr: SocketAddr) {
if let Some(main_addr) = self.nodes.get(&node_id) {
@ -512,6 +519,8 @@ impl<P: Protocol> GenericCloud<P> {
try!(self.connect(p));
}
}
// Refresh peer
self.peers.refresh(&peer);
},
Message::Init(stage, node_id, ranges) => {
// Avoid connecting to self