6 """encapsulate contact info"""
7 def __init__(self, id, host, port):
9 self.int = hash.intify(id)
12 self.lastSeen = time.time()
14 def updateLastSeen(self):
15 self.lastSeen = time.time()
18 return `(self.id, self.host, self.port)`
20 ## these comparators let us bisect/index a list full of nodes with either a node or an int/long
22 if type(a) == InstanceType:
26 if type(a) == InstanceType:
30 if type(a) == InstanceType:
34 if type(a) == InstanceType:
38 if type(a) == InstanceType:
42 if type(a) == InstanceType:
49 class TestNode(unittest.TestCase):
51 self.node = Node(hash.newID(), 'localhost', 2002)
52 def testUpdateLastSeen(self):
53 t = self.node.lastSeen
54 self.node.updateLastSeen()
55 assert t < self.node.lastSeen