reactor.installResolver(BlockingResolver())
from allmydata.storageserver import StorageServer
+from allmydata.util import idlib
class Client(service.MultiService, Referenceable):
implements(RIClient)
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()
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:
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.
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_
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
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
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)
from twisted.python import failure
from twisted.internet import defer
+from allmydata.util import idlib
class NotEnoughPeersError(Exception):
pass
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,
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:
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"