From: Brian Warner Date: Wed, 12 Mar 2008 02:33:19 +0000 (-0700) Subject: introducer: record a timestamp with each announcement, and display it on the introduc... X-Git-Tag: allmydata-tahoe-0.9.0~10 X-Git-Url: https://git.rkrishnan.org/uri/bar.txt?a=commitdiff_plain;h=45a1e655c7799bbf26fdc3751b5f8fd02ff22217;p=tahoe-lafs%2Ftahoe-lafs.git introducer: record a timestamp with each announcement, and display it on the introducer's web page --- diff --git a/src/allmydata/introducer.py b/src/allmydata/introducer.py index 98d969c4..4968d997 100644 --- a/src/allmydata/introducer.py +++ b/src/allmydata/introducer.py @@ -48,7 +48,7 @@ class IntroducerService(service.MultiService, Referenceable): 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): @@ -57,7 +57,7 @@ class IntroducerService(service.MultiService, Referenceable): return log.msg(*args, **kwargs) def get_announcements(self): - return frozenset(self._announcements) + return self._announcements def get_subscribers(self): return self._subscribers @@ -67,7 +67,7 @@ class IntroducerService(service.MultiService, Referenceable): 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])) diff --git a/src/allmydata/web/introweb.py b/src/allmydata/web/introweb.py index 7bee1631..97223573 100644 --- a/src/allmydata/web/introweb.py +++ b/src/allmydata/web/introweb.py @@ -43,13 +43,13 @@ class IntroducerRoot(rend.Page): 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 @@ -58,8 +58,9 @@ class IntroducerRoot(rend.Page): 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