]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
don't over-encode the nodeid many times with ascii-encoding
authorZooko O'Whielacronx <zooko@zooko.com>
Sun, 12 Aug 2007 17:29:38 +0000 (10:29 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Sun, 12 Aug 2007 17:29:38 +0000 (10:29 -0700)
src/allmydata/node.py
src/allmydata/test/test_system.py
src/allmydata/webish.py

index 8c99a89fb7a3fa5c6e2a923c6b862d365dd65b16..d3612b0d362f72ae0403385759d8e38f574fba5f 100644 (file)
@@ -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:
index a1948eb19acce25b453595b6097c05aec3de45fb..eb5eaf600d1fa13ef63b1df984a038629b13bf2f 100644 (file)
@@ -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: <span>%s</span>" % idlib.b2a(self.clients[0].nodeid)
+            expected = "My nodeid: <span>%s</span>" % (b32encode(self.clients[0].nodeid).lower(),)
             self.failUnless(expected in page,
                             "I didn't see the right 'My nodeid' message "
                             "in: %s" % page)
index c4aafc5531bf760e526e5e419f655d27ef794853..812d43f99871ed43ff8dc6a6a5a2b7992645e0bb 100644 (file)
@@ -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