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 {'id': self.id, 'port' : self.port, 'host' : self.host}
21 return `(self.id, self.host, self.port)`
23 ## these comparators let us bisect/index a list full of nodes with either a node or an int/long
25 if type(a) == InstanceType:
29 if type(a) == InstanceType:
33 if type(a) == InstanceType:
37 if type(a) == InstanceType:
41 if type(a) == InstanceType:
45 if type(a) == InstanceType:
52 class TestNode(unittest.TestCase):
54 self.node = Node(hash.newID(), 'localhost', 2002)
55 def testUpdateLastSeen(self):
56 t = self.node.lastSeen
57 self.node.updateLastSeen()
58 assert t < self.node.lastSeen