From: kevan Date: Sun, 25 Sep 2011 00:41:34 +0000 (-0700) Subject: mutable/layout: break unpack_checkstring into unpack_mdmf_checkstring and unpack_sdmf... X-Git-Tag: allmydata-tahoe-1.9.0a2~8 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/provisioning?a=commitdiff_plain;h=e8afe848137d4c41bb7e9467b4d0b119dd2967e1;p=tahoe-lafs%2Ftahoe-lafs.git mutable/layout: break unpack_checkstring into unpack_mdmf_checkstring and unpack_sdmf_checkstring, add distinguisher function for checkstrings --- diff --git a/src/allmydata/mutable/layout.py b/src/allmydata/mutable/layout.py index 55f39685..91486957 100644 --- a/src/allmydata/mutable/layout.py +++ b/src/allmydata/mutable/layout.py @@ -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,