mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-01 08:48:01 +00:00
introducer: record a timestamp with each announcement, and display it on the introducer's web page
This commit is contained in:
parent
29e23626ad
commit
45a1e655c7
@ -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]))
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user