def __init__(self, basedir="."):
service.MultiService.__init__(self)
self.introducer_url = None
- self._announcements = set()
+ self._announcements = {} # dict of (announcement)->timestamp
self._subscribers = {} # dict of (rref->timestamp) dicts
def log(self, *args, **kwargs):
return log.msg(*args, **kwargs)
def get_announcements(self):
- return frozenset(self._announcements)
+ return self._announcements
def get_subscribers(self):
return self._subscribers
if announcement in self._announcements:
self.log("but we already knew it, ignoring", level=log.NOISY)
return
- self._announcements.add(announcement)
+ self._announcements[announcement] = time.time()
for s in self._subscribers.get(service_name, []):
s.callRemote("announce", set([announcement]))
def data_services(self, ctx, data):
i = IClient(ctx).getServiceNamed("introducer")
- ann = [a
- for a in i.get_announcements()
+ ann = [(since,a)
+ for (a,since) in i.get_announcements().items()
if a[1] != "stub_client"]
- ann.sort(lambda a,b: cmp( (a[1], a), (b[1], b) ) )
+ ann.sort(lambda a,b: cmp( (a[1][1], a), (b[1][1], b) ) )
return ann
- def render_service_row(self, ctx, announcement):
+ def render_service_row(self, ctx, (since,announcement)):
(furl, service_name, ri_name, nickname, ver, oldest) = announcement
sr = SturdyRef(furl)
nodeid = sr.tubID
ctx.fillSlots("peerid", "%s %s" % (nodeid, nickname))
ctx.fillSlots("advertised", " ".join(advertised))
ctx.fillSlots("connected", "?")
- ctx.fillSlots("since", "?")
- ctx.fillSlots("announced", "?")
+ TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
+ ctx.fillSlots("announced",
+ time.strftime(TIME_FORMAT, time.localtime(since)))
ctx.fillSlots("version", ver)
ctx.fillSlots("service_name", service_name)
return ctx.tag