]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Miscellaneous corrections and additions.
authorDavid-Sarah Hopwood <david-sarah@jacaranda.org>
Wed, 12 Dec 2012 07:04:31 +0000 (07:04 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 10 Jul 2015 03:35:30 +0000 (04:35 +0100)
Signed-off-by: David-Sarah Hopwood <david-sarah@jacaranda.org>
src/allmydata/immutable/layout.py
src/allmydata/immutable/upload.py
src/allmydata/interfaces.py
src/allmydata/mutable/filenode.py
src/allmydata/mutable/layout.py
src/allmydata/storage/common.py
src/allmydata/web/storage.py

index 8d9a8f03546eacf6bb2693f302bb1698c1ddc425..5d0a70dade3c1f04062cf2f05dc3898dd4e1ec54 100644 (file)
@@ -337,7 +337,7 @@ class ReadBucketProxy:
         return self._read(0, 0x44)
 
     def _parse_offsets(self, data):
-        precondition(len(data) >= 0x4)
+        precondition(len(data) >= 0x4, len(data))
         self._offsets = {}
         (version,) = struct.unpack(">L", data[0:4])
         if version != 1 and version != 2:
index c63240463cd1a510d411e8939d746fb3a5cd0b4f..55d2d4d069a156d296a3c6715f52e5918812ff01 100644 (file)
@@ -815,8 +815,26 @@ class EncryptAnUploadable:
             self._status.set_progress(1, progress)
         return cryptdata
 
-
     def get_plaintext_hashtree_leaves(self, first, last, num_segments):
+        """OBSOLETE; Get the leaf nodes of a merkle hash tree over the
+        plaintext segments, i.e. get the tagged hashes of the given segments.
+        The segment size is expected to be generated by the
+        IEncryptedUploadable before any plaintext is read or ciphertext
+        produced, so that the segment hashes can be generated with only a
+        single pass.
+
+        This returns a Deferred that fires with a sequence of hashes, using:
+
+         tuple(segment_hashes[first:last])
+
+        'num_segments' is used to assert that the number of segments that the
+        IEncryptedUploadable handled matches the number of segments that the
+        encoder was expecting.
+
+        This method must not be called until the final byte has been read
+        from read_encrypted(). Once this method is called, read_encrypted()
+        can never be called again.
+        """
         # this is currently unused, but will live again when we fix #453
         if len(self._plaintext_segment_hashes) < num_segments:
             # close out the last one
@@ -835,6 +853,12 @@ class EncryptAnUploadable:
         return defer.succeed(tuple(self._plaintext_segment_hashes[first:last]))
 
     def get_plaintext_hash(self):
+        """OBSOLETE; Get the hash of the whole plaintext.
+
+        This returns a Deferred that fires with a tagged SHA-256 hash of the
+        whole plaintext, obtained from hashutil.plaintext_hash(data).
+        """
+        # this is currently unused, but will live again when we fix #453
         h = self._plaintext_hasher.digest()
         return defer.succeed(h)
 
index f322db822762bbeb8f18201eb53e453688e476e2..772127c8a58cf3829870f964e1edf6cbd4d5ef5e 100644 (file)
@@ -1502,7 +1502,7 @@ class IDirectoryNode(IFilesystemNode):
         is empty, the metadata will be an empty dictionary.
         """
 
-    def set_uri(name, writecap, readcap=None, metadata=None, overwrite=True):
+    def set_uri(name, writecap, readcap, metadata=None, overwrite=True):
         """I add a child (by writecap+readcap) at the specific name. I return
         a Deferred that fires when the operation finishes. If overwrite= is
         True, I will replace any existing child of the same name, otherwise
index 50bbdd34e06910c8166357aac2177446c80a229f..5757d7966f4619965a1b2b1043cd01a4416f974e 100644 (file)
@@ -742,8 +742,9 @@ class MutableFileVersion:
         """
         return self._version[0] # verinfo[0] == the sequence number
 
+    def get_servermap(self):
+        return self._servermap
 
-    # TODO: Terminology?
     def get_writekey(self):
         """
         I return a writekey or None if I don't have a writekey.
index 7e20996ffa36a929c364c9248ef94b6be219e79a..f018ca7e5125ec84f3c1cbbc6e62f1eca9372c02 100644 (file)
@@ -96,7 +96,7 @@ def unpack_header(data):
     return (version, seqnum, root_hash, IV, k, N, segsize, datalen, o)
 
 def unpack_share(data):
-    assert len(data) >= HEADER_LENGTH
+    assert len(data) >= HEADER_LENGTH, len(data)
     o = {}
     (version,
      seqnum,
index 3a5e0dce22211c75440786c02651c27b43f95da9..d2170426876972ee00d4f5f9ab9df0b61fe0d72d 100644 (file)
@@ -1,12 +1,25 @@
 
-import os.path
+import os, re
+
 from allmydata.util import base32
 
+
+# Share numbers match this regex:
+NUM_RE=re.compile("^[0-9]+$")
+
+PREFIX = re.compile("^[%s]{2}$" % (base32.z_base_32_alphabet,))
+
+
 class DataTooLargeError(Exception):
     pass
-class UnknownMutableContainerVersionError(Exception):
+
+class UnknownContainerVersionError(Exception):
+    pass
+
+class UnknownMutableContainerVersionError(UnknownContainerVersionError):
     pass
-class UnknownImmutableContainerVersionError(Exception):
+
+class UnknownImmutableContainerVersionError(UnknownContainerVersionError):
     pass
 
 
index 19d40e18b989901d13df09f911656fd0859d4a6d..59478b9ee276416e0523d4cafe1693662340087f 100644 (file)
@@ -40,7 +40,7 @@ class StorageStatus(rend.Page):
     def data_nickname(self, ctx, storage):
         return self.nickname
     def data_nodeid(self, ctx, storage):
-        return idlib.nodeid_b2a(self.storage.get_nodeid())
+        return idlib.nodeid_b2a(self.storage.get_serverid())
 
     def render_storage_running(self, ctx, storage):
         if storage: