From: Zooko O'Whielacronx Date: Sun, 12 Aug 2007 17:29:38 +0000 (-0700) Subject: don't over-encode the nodeid many times with ascii-encoding X-Git-Url: https://git.rkrishnan.org/pf/content/en/footer/frontends?a=commitdiff_plain;h=42f8e574169b87a7bf41ec043baa28ad2f5a2812;p=tahoe-lafs%2Ftahoe-lafs.git don't over-encode the nodeid many times with ascii-encoding --- diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 8c99a89f..d3612b0d 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -1,6 +1,6 @@ -from base64 import b32encode import os.path, re +from base64 import b32decode, b32encode import twisted from twisted.python import log @@ -36,13 +36,11 @@ class Node(service.MultiService): self.tub = Tub(certFile=certfile) self.tub.setOption("logLocalFailures", True) self.tub.setOption("logRemoteFailures", True) - # I think self.nodeid is kind of whacked. Shouldn't it equal the - # fingerprint portion of our furl? - self.nodeid = b32encode(self.tub.tubID).lower() + self.nodeid = b32decode(self.tub.tubID.upper()) # binary format f = open(os.path.join(self.basedir, self.NODEIDFILE), "w") f.write(b32encode(self.nodeid).lower() + "\n") f.close() - self.short_nodeid = self.tub.tubID[:4] # ready for printing + self.short_nodeid = b32encode(self.nodeid).lower()[:8] # ready for printing assert self.PORTNUMFILE, "Your node.Node subclass must provide PORTNUMFILE" self._portnumfile = os.path.join(self.basedir, self.PORTNUMFILE) try: diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index a1948eb1..eb5eaf60 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -1,4 +1,5 @@ +from base64 import b32decode, b32encode import os from cStringIO import StringIO from twisted.trial import unittest @@ -496,7 +497,7 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase): "I didn't see the right 'connected peers' message " "in: %s" % page ) - expected = "My nodeid: %s" % idlib.b2a(self.clients[0].nodeid) + expected = "My nodeid: %s" % (b32encode(self.clients[0].nodeid).lower(),) self.failUnless(expected in page, "I didn't see the right 'My nodeid' message " "in: %s" % page) diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index c4aafc55..812d43f9 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -1,4 +1,5 @@ +from base64 import b32decode, b32encode import os.path from twisted.application import service, strports from twisted.web import static, resource, server, html, http @@ -985,7 +986,7 @@ class Root(rend.Page): (v['allmydata'], v['zfec'], v['foolscap'], v['twisted']) def data_my_nodeid(self, ctx, data): - return idlib.b2a(IClient(ctx).nodeid) + return b32encode(IClient(ctx).nodeid).lower() def data_introducer_furl(self, ctx, data): return IClient(ctx).introducer_furl def data_connected_to_introducer(self, ctx, data): @@ -1005,7 +1006,7 @@ class Root(rend.Page): d = [] client = IClient(ctx) for nodeid in sorted(client.get_all_peerids()): - row = (idlib.b2a(nodeid),) + row = (b32encode(nodeid).lower(),) d.append(row) return d