]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
don't return duplicates if we have a key in our store
authorburris <burris>
Sat, 14 Sep 2002 00:37:51 +0000 (00:37 +0000)
committerburris <burris>
Sat, 14 Sep 2002 00:37:51 +0000 (00:37 +0000)
actions.py
khashmir.py

index 0a6062f0ee136f21a35af19e29d0b07ed1bdbb93..945832970cf3a5467a50b3d1d4211cea3e7648c1 100644 (file)
@@ -165,8 +165,11 @@ class GetValue(FindNode):
            reactor.callFromThread(self.callback,[])
     
     ## get value
-    def goWithNodes(self, nodes):
+    def goWithNodes(self, nodes, found=None):
        self.results = {}
+       if found:
+           for n in found:
+               self.results[n] = 1
        for node in nodes:
            if node.id == self.table.node.id:
                continue
index 8ef62211501bfd06e38c83339b6c93b7255e0a48..893bd02f6b64f7034af6882cbc6855445325c470 100644 (file)
@@ -92,15 +92,17 @@ class Khashmir(xmlrpc.XMLRPC):
     def valueForKey(self, key, callback):
        """ returns the values found for key in global table """
        nodes = self.table.findNodes(key)
-       # create our search state
-       state = GetValue(self, key, callback)
-       reactor.callFromThread(state.goWithNodes, nodes)
-       
+
        # get locals
        l = self.retrieveValues(key)
        if len(l) > 0:
            reactor.callFromThread(callback, l)
 
+       # create our search state
+       state = GetValue(self, key, callback)
+       reactor.callFromThread(state.goWithNodes, nodes, {'found' : l})
+       
+
 
     ## async, but in the current implementation there is no guarantee a store does anything so there is no callback right now
     def storeValueForKey(self, key, value, callback=None):