]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - node.py
Make it also work from the command-line.
[quix0rs-apt-p2p.git] / node.py
diff --git a/node.py b/node.py
index 93e16052c2e9d92ddc9f45f8a89c80e4f4d08767..35dadc6eebc52ecff3d11a03616557f33ca4be17 100644 (file)
--- a/node.py
+++ b/node.py
@@ -1,6 +1,10 @@
-import hash
-import time
-from types import *
+## Copyright 2002-2003 Andrew Loewenstern, All Rights Reserved
+# see LICENSE.txt for license information
+
+from time import time
+from types import InstanceType
+
+import khash
 
 class Node:
     """encapsulate contact info"""
@@ -11,7 +15,7 @@ class Node:
     
     def init(self, id, host, port):
         self.id = id
-        self.num = hash.intify(id)
+        self.num = khash.intify(id)
         self.host = host
         self.port = port
         self._senderDict = {'id': self.id, 'port' : self.port, 'host' : self.host}
@@ -20,13 +24,13 @@ class Node:
     def initWithDict(self, dict):
         self._senderDict = dict
         self.id = dict['id']
-        self.num = hash.intify(self.id)
+        self.num = khash.intify(self.id)
         self.port = dict['port']
         self.host = dict['host']
         return self
     
     def updateLastSeen(self):
-        self.lastSeen = time.time()
+        self.lastSeen = time()
         self.fails = 0
     
     def msgFailed(self):
@@ -70,7 +74,7 @@ import unittest
 
 class TestNode(unittest.TestCase):
     def setUp(self):
-        self.node = Node().init(hash.newID(), 'localhost', 2002)
+        self.node = Node().init(khash.newID(), 'localhost', 2002)
     def testUpdateLastSeen(self):
         t = self.node.lastSeen
         self.node.updateLastSeen()