]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
standardize on keeping nodeids (and all other SHA1-derived values as binary everywher...
authorBrian Warner <warner@lothar.com>
Sat, 2 Dec 2006 23:26:26 +0000 (16:26 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 2 Dec 2006 23:26:26 +0000 (16:26 -0700)
allmydata/client.py
allmydata/interfaces.py
allmydata/queen.py
allmydata/upload.py

index 9b8ed7ead45a8b00af860572968d9aabd1c867bb..7ad410539629f36c0ddcc8d7fd01cf32005a64df 100644 (file)
@@ -16,6 +16,7 @@ from twisted.internet.base import BlockingResolver
 reactor.installResolver(BlockingResolver())
 
 from allmydata.storageserver import StorageServer
+from allmydata.util import idlib
 
 class Client(service.MultiService, Referenceable):
     implements(RIClient)
@@ -32,7 +33,7 @@ class Client(service.MultiService, Referenceable):
             f = open(self.CERTFILE, "wb")
             f.write(self.tub.getCertData())
             f.close()
-        self.nodeid = self.tub.tubID
+        self.nodeid = idlib.a2b(self.tub.tubID)
         self.tub.setServiceParent(self)
         self.queen = None # self.queen is either None or a RemoteReference
         self.all_peers = set()
@@ -90,21 +91,21 @@ class Client(service.MultiService, Referenceable):
         for nodeid, pburl in new_peers:
             if nodeid == self.nodeid:
                 continue
-            log.msg("adding peer %s" % nodeid)
+            log.msg("adding peer %s" % idlib.b2a(nodeid))
             if nodeid in self.all_peers:
                 log.msg("weird, I already had an entry for them")
             self.all_peers.add(nodeid)
             if nodeid not in self.connections:
                 d = self.tub.getReference(pburl)
                 def _got_reference(ref):
-                    log.msg("connected to %s" % nodeid)
+                    log.msg("connected to %s" % idlib.b2a(nodeid))
                     if nodeid in self.all_peers:
                         self.connections[nodeid] = ref
                 d.addCallback(_got_reference)
 
     def remote_lost_peers(self, lost_peers):
         for nodeid in lost_peers:
-            log.msg("lost peer %s" % nodeid)
+            log.msg("lost peer %s" % idlib.b2a(nodeid))
             if nodeid in self.all_peers:
                 self.all_peers.remove(nodeid)
             else:
index 0bacbd439c470b7d3ae0d220b7fc8a174ce90278..dd45a28a5c41f43c69780436517bcb6fd40e5bb5 100644 (file)
@@ -2,9 +2,9 @@
 from foolscap.schema import StringConstraint, ListOf, TupleOf, Any, Nothing
 from foolscap import RemoteInterface
 
-Nodeid = StringConstraint(20) # base32 encoded 20-byte SHA1 hash
-PBURL = StringConstraint()
-Tubid = StringConstraint()
+Nodeid = StringConstraint(20) # binary format 20-byte SHA1 hash
+PBURL = StringConstraint(150)
+Verifierid = StringConstraint(20)
 ShareData = StringConstraint(20000)
 # these three are here because Foolscap does not yet support the kind of
 # restriction I really want to apply to these.
@@ -25,8 +25,8 @@ class RIClient(RemoteInterface):
         return Nothing()
 
 class RIStorageServer(RemoteInterface):
-    def allocate_bucket(verifierid=Nodeid, bucket_num=int, size=int,
-                        leaser=Tubid):
+    def allocate_bucket(verifierid=Verifierid, bucket_num=int, size=int,
+                        leaser=Nodeid):
         return RIBucketWriter_
 
 
index 0934b489884de50b8ce2c05292ef8138203c4874..0a75a93005a03667f3751435d32cc3dfa6a5ffec 100644 (file)
@@ -5,6 +5,7 @@ from twisted.application import service
 from twisted.python import log
 import os.path
 from allmydata.util.iputil import get_local_ip_for
+from allmydata.util import idlib
 from zope.interface import implements
 from allmydata.interfaces import RIQueenRoster
 
@@ -17,7 +18,7 @@ class Roster(service.MultiService, Referenceable):
         self.connections = {}
 
     def remote_hello(self, nodeid, node, pburl):
-        log.msg("contact from %s" % nodeid)
+        log.msg("contact from %s" % idlib.b2a(nodeid))
         eventually(self._educate_the_new_peer, node)
         eventually(self._announce_new_peer, nodeid, pburl)
         self.phonebook[nodeid] = pburl
@@ -33,7 +34,7 @@ class Roster(service.MultiService, Referenceable):
                                   new_peers=[(new_nodeid, new_node_pburl)])
 
     def _lost_node(self, nodeid):
-        log.msg("lost contact with %s" % nodeid)
+        log.msg("lost contact with %s" % idlib.b2a(nodeid))
         del self.phonebook[nodeid]
         del self.connections[nodeid]
         eventually(self._announce_lost_peer, nodeid)
index ae659c03cc2066519c3bd4af1525401b526846cd..b6dc4de07572d9f7e0bf14706fe5815f821ce578 100644 (file)
@@ -1,6 +1,7 @@
 
 from twisted.python import failure
 from twisted.internet import defer
+from allmydata.util import idlib
 
 class NotEnoughPeersError(Exception):
     pass
@@ -64,7 +65,7 @@ class Uploader:
         d = self._peer.get_remote_service(peerid, "storageserver")
         def _got_peer(service):
             bucket_num = len(self.landlords)
-            if self.debug: print "asking %s" % peerid
+            if self.debug: print "asking %s" % idlib.b2a(peerid)
             d2 = service.callRemote("allocate_bucket",
                                     verifierid=self._verifierid,
                                     bucket_num=bucket_num,
@@ -72,7 +73,7 @@ class Uploader:
                                     leaser=self._peer.nodeid)
             def _allocate_response(bucket):
                 if self.debug:
-                    print " peerid %s will grant us a lease" % peerid
+                    print " peerid %s will grant us a lease" % idlib.b2a(peerid)
                 self.landlords.append( (peerid, bucket_num, bucket) )
                 self.goodness_points += 1
                 if self.goodness_points >= self.target_goodness:
@@ -83,7 +84,7 @@ class Uploader:
             return d2
         d.addCallback(_got_peer)
         def _done_with_peer(res):
-            if self.debug: print "done with peer %s:" % peerid
+            if self.debug: print "done with peer %s:" % idlib.b2a(peerid)
             if isinstance(res, failure.Failure):
                 if res.check(HaveAllPeersError):
                     if self.debug: print " all done"