From b67d64cc271cd334cfc49e98107b88655885514d Mon Sep 17 00:00:00 2001 From: burris Date: Sun, 22 Sep 2002 07:38:55 +0000 Subject: [PATCH] fix bug where less than K nodes were being utilized from the seed nodes of find nodes/values requests --- actions.py | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/actions.py b/actions.py index e6d5350..13b3864 100644 --- a/actions.py +++ b/actions.py @@ -68,7 +68,7 @@ class FindNode(ActionBase): 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]) @@ -103,17 +103,10 @@ class FindNode(ActionBase): 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 @@ -157,7 +150,7 @@ class GetValue(FindNode): 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()) @@ -182,18 +175,10 @@ class GetValue(FindNode): 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() -- 2.39.5