From: david-sarah Date: Sun, 25 Sep 2011 02:36:51 +0000 (-0700) Subject: mutable/layout.py: make unpack_sdmf_checkstring and unpack_mdmf_checkstring more... X-Git-Tag: allmydata-tahoe-1.9.0a2~6 X-Git-Url: https://git.rkrishnan.org/%3C?a=commitdiff_plain;h=c88adf0ac0e10000ba43fae796345a6d570c3291;p=tahoe-lafs%2Ftahoe-lafs.git mutable/layout.py: make unpack_sdmf_checkstring and unpack_mdmf_checkstring more similar, and change an assert to give a more useful message if it fails. refs #1540 --- diff --git a/src/allmydata/mutable/layout.py b/src/allmydata/mutable/layout.py index 91486957..84894014 100644 --- a/src/allmydata/mutable/layout.py +++ b/src/allmydata/mutable/layout.py @@ -143,16 +143,13 @@ def get_version_from_checkstring(checkstring): 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) + assert version == SDMF_VERSION, 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 + version, seqnum, root_hash = struct.unpack(MDMFCHECKSTRING, checkstring[:cs_len]) + assert version == MDMF_VERSION, version return (seqnum, root_hash) def pack_offsets(verification_key_length, signature_length, diff --git a/src/allmydata/mutable/publish.py b/src/allmydata/mutable/publish.py index 8e4ef514..036bf51d 100644 --- a/src/allmydata/mutable/publish.py +++ b/src/allmydata/mutable/publish.py @@ -1112,7 +1112,7 @@ class Publish: elif version == SDMF_VERSION: (other_seqnum, other_roothash, - other_salt) = unpack_sdmf_checkstring(checkstring) + other_IV) = unpack_sdmf_checkstring(checkstring) else: unknown_format = True expected_version = self._servermap.version_on_peer(peerid,