def _nodesFound(self, responses): """ Handle the result of an iteration in C{_find}. """ toremove = [] foundValues = [] for peerid, response in responses.items(): response = RPCFindResponse(response) if not response.happened(): toremove.append(peerid) elif response.hasValue(): foundValues.append((peerid, response.getValue())) else: peer = self.nearest.getNodeById(peerid) self.nearestWithoutValue.push(peer) self.nearest.push(response.getNodeList()) _log.debug("_nodesFound nearestWithoutValue: %s, nearest: %s, toremove: %s" % (self.nearestWithoutValue.getIDs(), self.nearest.getIDs(), toremove)) self.nearest.remove(toremove) if len(foundValues) > 0: return self._handleFoundValues(foundValues) if self.nearest.allBeenContacted(): # not found at neighbours! if self.local_value: # but we had it return self.local_value else: return None return self.find()
def _nodesFound(self, responses): """ Handle the result of an iteration in _find. """ toremove = [] for peerid, response in responses.items(): response = RPCFindResponse(response) if not response.happened(): toremove.append(peerid) else: self.nearest.push(response.getNodeList()) self.nearest.remove(toremove) if self.nearest.allBeenContacted(): self.time_keeper.stop_clock(ENTRY_CRAWL_NEAREST) self.is_first = True return list(self.nearest) return self.find()
def _nodesFound(self, responses): """ Handle the result of an iteration in C{_find}. """ toremove = [] foundValues = [] for peerid, response in responses.items(): response = RPCFindResponse(response) if not response.happened(): toremove.append(peerid) elif response.hasValue(): foundValues.append((peerid, response.getValue())) else: peer = self.nearest.getNodeById(peerid) self.nearestWithoutValue.push(peer) self.nearest.push(response.getNodeList()) _log.debug( "_nodesFound nearestWithoutValue: %s, nearest: %s, toremove: %s" % (self.nearestWithoutValue.getIDs(), self.nearest.getIDs(), toremove)) self.nearest.remove(toremove) if len(foundValues) > 0: return self._handleFoundValues(foundValues) if self.nearest.allBeenContacted(): # not found at neighbours! if self.local_value: # but we had it return self.local_value else: return None return self.find()
def _nodesFound(self, responses): """ Handle the result of an iteration in C{_find}. """ toremove = [] foundValues = [] for peerid, response in responses.items(): response = RPCFindResponse(response) if not response.happened(): toremove.append(peerid) elif response.hasValue(): foundValues.append((peerid, response.getValue())) else: peer = self.nearest.getNodeById(peerid) self.nearestWithoutValue.push(peer) self.nearest.push(response.getNodeList()) self.nearest.remove(toremove) if len(foundValues) > 0: return self._handleFoundValues(foundValues) if self.nearest.allBeenContacted(): # not found! return None return self.find()