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
This commit is contained in:
parent
70d27cfa7c
commit
c88adf0ac0
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue