From: Cameron Dale Date: Sat, 10 May 2008 05:19:42 +0000 (-0700) Subject: Schedule a re-ping message after adding a new node. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=19da87ea5f64e0280c31385a7599bd82b27d28a4;p=quix0rs-apt-p2p.git Schedule a re-ping message after adding a new node. Also fixed a typo in the new nodeFailed function. --- diff --git a/apt_p2p_Khashmir/khashmir.py b/apt_p2p_Khashmir/khashmir.py index 607c49b..54951b7 100644 --- a/apt_p2p_Khashmir/khashmir.py +++ b/apt_p2p_Khashmir/khashmir.py @@ -226,7 +226,13 @@ class KhashmirBase(protocol.Factory): df.addErrback(self._staleNodeHandler, old, node, contacted) elif not old and not contacted: # There's room, we just need to contact the node first - self.sendPing(node) + df = self.sendPing(node) + # Also schedule a future ping to make sure the node works + def rePing(newnode, self = self): + if newnode.id not in self.pinging: + self.pinging[newnode.id] = reactor.callLater(self.config['MIN_PING_INTERVAL'], + self.sendPing, newnode) + df.addCallback(rePing) def _staleNodeHandler(self, err, old, node, contacted): """The pinged node never responded, so replace it.""" @@ -244,7 +250,7 @@ class KhashmirBase(protocol.Factory): # If in the table, schedule a ping, if one isn't already sent/scheduled if exists and node.id not in self.pinging: - self.pinging[node,id] = reactor.callLater(self.config['MIN_PING_INTERVAL'], + self.pinging[node.id] = reactor.callLater(self.config['MIN_PING_INTERVAL'], self.sendPing, node) def sendPing(self, node):