2 from foolscap.schema import StringConstraint, ListOf, TupleOf, Any, Nothing
3 from foolscap import RemoteInterface
5 Nodeid = StringConstraint(20) # binary format 20-byte SHA1 hash
6 PBURL = StringConstraint(150)
7 Verifierid = StringConstraint(20)
8 ShareData = StringConstraint(100000)
9 # these four are here because Foolscap does not yet support the kind of
10 # restriction I really want to apply to these.
12 Referenceable_ = Any()
13 RIBucketWriter_ = Any()
14 RIBucketReader_ = Any()
15 RIMutableDirectoryNode_ = Any()
16 RIMutableFileNode_ = Any()
18 class RIQueenRoster(RemoteInterface):
19 def hello(nodeid=Nodeid, node=RIClient_, pburl=PBURL):
20 return RIMutableDirectoryNode_ # the virtual drive root
22 class RIClient(RemoteInterface):
23 def get_service(name=str):
25 def add_peers(new_peers=ListOf(TupleOf(Nodeid, PBURL), maxLength=100)):
27 def lost_peers(lost_peers=ListOf(Nodeid)):
30 class RIStorageServer(RemoteInterface):
31 def allocate_bucket(verifierid=Verifierid, bucket_num=int, size=int,
32 leaser=Nodeid, canary=Referenceable_):
33 # if the canary is lost before close(), the bucket is deleted
34 return RIBucketWriter_
35 def get_buckets(verifierid=Verifierid):
36 return ListOf(TupleOf(int, RIBucketReader_))
38 class RIBucketWriter(RemoteInterface):
39 def write(data=ShareData):
46 class RIBucketReader(RemoteInterface):
51 class RIMutableDirectoryNode(RemoteInterface):
53 return ListOf( TupleOf(str, # name, relative to directory
54 (RIMutableDirectoryNode_, Verifierid)),
59 return (RIMutableDirectoryNode_, Verifierid)
61 def add_directory(name=str):
62 return RIMutableDirectoryNode_
64 def add_file(name=str, data=Verifierid):
70 # need more to move directories
72 # TODO: figleaf gets confused when the last line of a file is a comment. I
73 # suspect an off-by-one error in the code that decides which lines are code