From c88adf0ac0e10000ba43fae796345a6d570c3291 Mon Sep 17 00:00:00 2001 From: david-sarah <david-sarah@jacaranda.org> Date: Sat, 24 Sep 2011 19:36:51 -0700 Subject: [PATCH] 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 --- src/allmydata/mutable/layout.py | 9 +++------ src/allmydata/mutable/publish.py | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) 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, -- 2.45.2