]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
allmydata.interfaces: remove some of the placeholders now that we require foolscap...
authorBrian Warner <warner@lothar.com>
Wed, 4 Apr 2007 22:59:36 +0000 (15:59 -0700)
committerBrian Warner <warner@lothar.com>
Wed, 4 Apr 2007 22:59:36 +0000 (15:59 -0700)
README
src/allmydata/interfaces.py
src/allmydata/storageserver.py

diff --git a/README b/README
index 48624ab3bbdd5548644ab88141ea10ce0c598c27..c81fd7887768f4cfd3ea03f04291da03934e6d16 100644 (file)
--- a/README
+++ b/README
@@ -21,7 +21,7 @@ DEPENDENCIES:
    * web, trial, conch
   Note that Twisted requires zope.interface, and that the standard
   batteries-included Twisted distribution includes a copy.
- Foolscap (probably 0.0.7 or newer)
+ Foolscap (0.1.2 or newer)
   - note: since the Foolscap wire protocol is not yet compatible from one
     release to the next, make sure all of your nodes are using the same
     version of Foolscap
index 4cb69ba514b6a08cd903227427117fca6e964737..099a79e7410844a49be4a7d968951e18fb4c287f 100644 (file)
@@ -1,26 +1,19 @@
 
 from zope.interface import Interface
-from foolscap.schema import StringConstraint, ListOf, TupleOf, Any
-from foolscap import RemoteInterface
+from foolscap.schema import StringConstraint, ListOf, TupleOf, SetOf, DictOf
+from foolscap import RemoteInterface, Referenceable
 
 HASH_SIZE=32
 
-Hash = StringConstraint(HASH_SIZE) # binary format 32-byte SHA256 hash
-Nodeid = StringConstraint(20) # binary format 20-byte SHA1 hash
+Hash = StringConstraint(maxLength=HASH_SIZE,
+                        minLength=HASH_SIZE)# binary format 32-byte SHA256 hash
+Nodeid = StringConstraint(maxLength=20,
+                          minLength=20) # binary format 20-byte SHA1 hash
 PBURL = StringConstraint(150)
 Verifierid = StringConstraint(20)
 URI = StringConstraint(200) # kind of arbitrary
+MAX_BUCKETS = 200  # per peer
 ShareData = StringConstraint(100000)
-# these six are here because Foolscap does not yet support the kind of
-# restriction I really want to apply to these.
-RIClient_ = Any()
-Referenceable_ = Any()
-RIBucketWriter_ = Any()
-RIBucketReader_ = Any()
-RIMutableDirectoryNode_ = Any()
-RIMutableFileNode_ = Any()
-def SetOf(*args, **kwargs): return Any()
-def DictOf(*args, **kwargs): return Any()
 
 class RIIntroducerClient(RemoteInterface):
     def new_peers(pburls=SetOf(PBURL)):
@@ -32,7 +25,7 @@ class RIIntroducer(RemoteInterface):
 
 class RIClient(RemoteInterface):
     def get_service(name=str):
-        return Referenceable_
+        return Referenceable
     def get_nodeid():
         return Nodeid
 
@@ -57,18 +50,6 @@ class RIBucketWriter(RemoteInterface):
         """
         return None
 
-class RIStorageServer(RemoteInterface):
-    def allocate_buckets(verifierid=Verifierid, sharenums=SetOf(int),
-                         sharesize=int, blocksize=int, canary=Referenceable_):
-        """
-        @param canary: If the canary is lost before close(), the bucket is deleted.
-        @return: tuple of (alreadygot, allocated), where alreadygot is what we
-            already have and is what we hereby agree to accept
-        """
-        return TupleOf(SetOf(int), DictOf(int, RIBucketWriter))
-    def get_buckets(verifierid=Verifierid):
-        return DictOf(int, RIBucketReader_)
-
 class RIBucketReader(RemoteInterface):
     def get_block(blocknum=int):
         """Most blocks will be the same size. The last block might be shorter
@@ -80,6 +61,23 @@ class RIBucketReader(RemoteInterface):
     def get_share_hashes():
         return ListOf(TupleOf(int, Hash))
 
+class RIStorageServer(RemoteInterface):
+    def allocate_buckets(verifierid=Verifierid,
+                         sharenums=SetOf(int, maxLength=MAX_BUCKETS),
+                         sharesize=int, blocksize=int, canary=Referenceable):
+        """
+        @param canary: If the canary is lost before close(), the bucket is deleted.
+        @return: tuple of (alreadygot, allocated), where alreadygot is what we
+            already have and is what we hereby agree to accept
+        """
+        return TupleOf(SetOf(int, maxLength=MAX_BUCKETS),
+                       DictOf(int, RIBucketWriter, maxKeys=MAX_BUCKETS))
+    def get_buckets(verifierid=Verifierid):
+        return DictOf(int, RIBucketReader, maxKeys=MAX_BUCKETS)
+
+# hm, we need a solution for forward references in schemas
+from foolscap.schema import Any
+RIMutableDirectoryNode_ = Any() # TODO: how can we avoid this?
 class RIMutableDirectoryNode(RemoteInterface):
     def list():
         return ListOf( TupleOf(str, # name, relative to directory
index 0579c88dc3d11642cd3b7028f8b6125c1335e37c..df9b1a615cb846e201b88df63cda784c0bdcc28a 100644 (file)
@@ -4,7 +4,8 @@ from foolscap import Referenceable
 from twisted.application import service
 
 from zope.interface import implements
-from allmydata.interfaces import RIStorageServer, RIBucketWriter
+from allmydata.interfaces import RIStorageServer, RIBucketWriter, \
+     RIBucketReader
 from allmydata import interfaces
 from allmydata.util import bencode, fileutil, idlib
 from allmydata.util.assertutil import _assert, precondition
@@ -70,6 +71,8 @@ def str2l(s):
     return [ s[i:i+interfaces.HASH_SIZE] for i in range(0, len(s), interfaces.HASH_SIZE) ]
 
 class BucketReader(Referenceable):
+    implements(RIBucketReader)
+
     def __init__(self, home):
         self.home = home
         self.blocksize = int(self._read_file('blocksize'))