l = self.found.values()
l.sort(self.sort)
- for node in l[:K]:
+ for node in l:
if node.id == self.target:
self.finished=1
return self.callback([node])
for node in nodes:
if node.id == self.table.node.id:
continue
- self.found[node.id] = node
- #xxx t.timeout = time.time() + FIND_NODE_TIMEOUT
- df = node.findNode(self.target, self.table.node.senderDict())
- df.addCallbacks(self.handleGotNodes, self.makeMsgFailed(node))
- self.outstanding = self.outstanding + 1
- self.queried[node.id] = 1
- if self.outstanding >= const.CONCURRENT_REQS:
- break
-
- if self.outstanding == 0:
- self.callback(nodes)
+ else:
+ self.found[node.id] = node
+
+ self.schedule()
GET_VALUE_TIMEOUT = 15
l = self.found.values()
l.sort(self.sort)
- for node in l[:K]:
+ for node in l:
if not self.queried.has_key(node.id) and node.id != self.table.node.id:
#xxx t.timeout = time.time() + GET_VALUE_TIMEOUT
df = node.findValue(self.target, self.table.node.senderDict())
for node in nodes:
if node.id == self.table.node.id:
continue
- self.found[node.id] = node
- #xxx t.timeout = time.time() + FIND_NODE_TIMEOUT
- df = node.findValue(self.target, self.table.node.senderDict())
- df.addCallback(self.handleGotNodes)
- df.addErrback(self.makeMsgFailed(node))
- self.outstanding = self.outstanding + 1
- self.queried[node.id] = 1
- if self.outstanding >= const.CONCURRENT_REQS:
- break
-
- if self.outstanding == 0:
- reactor.callFromThread(self.callback, [])
+ else:
+ self.found[node.id] = node
+
+ self.schedule()