]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
all rpc's return ([<args>], {<sender}), previously ping did not
authorburris <burris>
Tue, 1 Oct 2002 05:10:09 +0000 (05:10 +0000)
committerburris <burris>
Tue, 1 Oct 2002 05:10:09 +0000 (05:10 +0000)
un hard-coded some constants

khashmir.py

index 390d8a9dcb0a458c47e40a66af7c4c286572a3fb..b2a624614abde817f1f1caf05fe4f9ed49c6adeb 100644 (file)
@@ -70,7 +70,7 @@ class Khashmir(xmlrpc.XMLRPC):
        """
         ping this node and add the contact info to the table on pong!
        """
-       n =Node().init(" "*20, host, port)  # note, we 
+       n =Node().init(const.NULL_ID, host, port)  # note, we 
        self.sendPing(n)
 
 
@@ -122,7 +122,7 @@ class Khashmir(xmlrpc.XMLRPC):
                    pass
                response=_storedValueHandler
        
-           for node in nodes:
+           for node in nodes[:const.STORE_REDUNDANCY]:
                def cb(t, table = table, node=node, resp=response):
                    self.table.insertNode(node)
                    response(t)
@@ -169,8 +169,9 @@ class Khashmir(xmlrpc.XMLRPC):
        """
        df = node.ping(self.node.senderDict())
        ## these are the callbacks we use when we issue a PING
-       def _pongHandler(sender, id=node.id, host=node.host, port=node.port, table=self.table):
-           if id != 20 * ' ' and id != sender['id'].data:
+       def _pongHandler(args, id=node.id, host=node.host, port=node.port, table=self.table):
+           l, sender = args
+           if id != const.NULL_ID and id != sender['id'].data:
                # whoah, got response from different peer than we were expecting
                pass
            else:
@@ -234,7 +235,7 @@ class Khashmir(xmlrpc.XMLRPC):
        sender['host'] = ip
        n = Node().initWithDict(sender)
        self.insertNode(n, contacted=0)
-       return self.node.senderDict()
+       return (), self.node.senderDict()
                
     def xmlrpc_find_node(self, target, sender):
        nodes = self.table.findNodes(target.data)
@@ -264,7 +265,7 @@ class Khashmir(xmlrpc.XMLRPC):
        sender['host'] = ip
        n = Node().initWithDict(sender)
        self.insertNode(n, contacted=0)
-       return self.node.senderDict()
+       return (), self.node.senderDict()
        
     def xmlrpc_find_value(self, key, sender):
        ip = self.crequest.getClientIP()
@@ -320,15 +321,15 @@ def test_build_net(quiet=0, peers=24, host='localhost',  pause=1):
        if pause:
            time.sleep(.5)
            
-    time.sleep(10)
+    time.sleep(1)
     print "finding close nodes...."
 
     for peer in l:
        peer.findCloseNodes()
        if pause:
-           time.sleep(2)
+           time.sleep(.5)
     if pause:
-           time.sleep(10)
+           time.sleep(1)
 #    for peer in l:
 #      peer.refreshTable()
     return l