mutable/layout: break unpack_checkstring into unpack_mdmf_checkstring and unpack_sdmf...
authorkevan <kevan@isnotajoke.com>
Sun, 25 Sep 2011 00:41:34 +0000 (17:41 -0700)
committerkevan <kevan@isnotajoke.com>
Sun, 25 Sep 2011 00:41:34 +0000 (17:41 -0700)
src/allmydata/mutable/layout.py

index 55f3968521e3fb1be5191f35fc0dcfa8f9277d6a..91486957c938682e0cabbdfa7d6d9b58f0ca4864 100644 (file)
@@ -136,13 +136,24 @@ def unpack_share(data):
             pubkey, signature, share_hash_chain, block_hash_tree,
             share_data, enc_privkey)
 
-def unpack_checkstring(checkstring):
+def get_version_from_checkstring(checkstring):
+    (t, ) = struct.unpack(">B", checkstring[:1])
+    return t
+
+def unpack_sdmf_checkstring(checkstring):
     cs_len = struct.calcsize(PREFIX)
     version, seqnum, root_hash, IV = struct.unpack(PREFIX, checkstring[:cs_len])
     if version != 0: # TODO: just ignore the share
         raise UnknownVersionError("got mutable share version %d, but I only understand version 0" % version)
     return (seqnum, root_hash, IV)
 
+def unpack_mdmf_checkstring(checkstring):
+    cs_len = struct.calcsize(MDMFCHECKSTRING)
+    checkstring = checkstring[:cs_len]
+    version, seqnum, root_hash = struct.unpack(MDMFCHECKSTRING, checkstring)
+
+    assert version == 1
+    return (seqnum, root_hash)
 
 def pack_offsets(verification_key_length, signature_length,
                  share_hash_chain_length, block_hash_tree_length,