'tahoe dump-share': show verify-cap too

This commit is contained in:
Brian Warner 2008-07-07 14:11:02 -07:00
parent 2074c92dd1
commit 9b6f23ac05
2 changed files with 30 additions and 2 deletions

View File

@ -12,6 +12,7 @@ class DumpOptions(usage.Options):
def dump_share(config, out=sys.stdout, err=sys.stderr):
from allmydata import uri, storage
from allmydata.util import base32
# check the version, to see if we have a mutable or immutable share
print >>out, "share filename: %s" % config['filename']
@ -61,6 +62,18 @@ def dump_share(config, out=sys.stdout, err=sys.stderr):
for k in sorted(leftover):
print >>out, "%20s: %s" % (k, unpacked[k])
# the storage index isn't stored in the share itself, so we depend upon
# knowing the parent directory name to get it
pieces = config['filename'].split(os.sep)
if len(pieces) >= 2 and base32.could_be_base32_encoded(pieces[-2]):
storage_index = base32.a2b(pieces[-2])
uri_extension_hash = base32.a2b(unpacked["UEB_hash"])
u = uri.CHKFileVerifierURI(storage_index, uri_extension_hash,
unpacked["needed_shares"],
unpacked["total_shares"], unpacked["size"])
verify_cap = u.to_string()
print >>out, "%20s: %s" % ("verify-cap", verify_cap)
sizes = {}
sizes['data'] = bp._data_size
sizes['validation'] = (offsets['uri_extension'] -
@ -145,7 +158,8 @@ def dump_mutable_share(config, out, err):
def dump_SDMF_share(offset, length, config, out, err):
from allmydata.mutable.layout import unpack_share
from allmydata.mutable.common import NeedMoreDataError
from allmydata.util import base32
from allmydata.util import base32, hashutil
from allmydata.uri import SSKVerifierURI
f = open(config['filename'], "rb")
f.seek(offset)
@ -183,6 +197,16 @@ def dump_SDMF_share(offset, length, config, out, err):
print >>out, " share_hash_chain: %s" % share_hash_ids
print >>out, " block_hash_tree: %d nodes" % len(block_hash_tree)
# the storage index isn't stored in the share itself, so we depend upon
# knowing the parent directory name to get it
pieces = config['filename'].split(os.sep)
if len(pieces) >= 2 and base32.could_be_base32_encoded(pieces[-2]):
storage_index = base32.a2b(pieces[-2])
fingerprint = hashutil.ssk_pubkey_fingerprint_hash(pubkey)
u = SSKVerifierURI(storage_index, fingerprint)
verify_cap = u.to_string()
print >>out, " verify-cap:", verify_cap
print >>out

View File

@ -11,7 +11,7 @@ import allmydata
from allmydata import client, uri, download, upload, storage, offloaded
from allmydata.introducer.server import IntroducerNode
from allmydata.util import deferredutil, fileutil, idlib, mathutil, testutil
from allmydata.util import log
from allmydata.util import log, base32
from allmydata.scripts import runner, cli
from allmydata.interfaces import IDirectoryNode, IFileNode, IFileURI
from allmydata.mutable.common import NotMutableError
@ -677,6 +677,9 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin,
# now
self.failUnless(" share_hash_chain: " in output)
self.failUnless(" block_hash_tree: 1 nodes\n" in output)
expected = (" verify-cap: URI:SSK-Verifier:%s:" %
base32.b2a(storage_index))
self.failUnless(expected in output)
except unittest.FailTest:
print
print "dump-share output was:"
@ -1458,6 +1461,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin,
"crypttext_hash", "crypttext_root_hash",
"share_root_hash", "UEB_hash"):
self.failUnless("%s: " % key in output, key)
self.failUnless(" verify-cap: URI:CHK-Verifier:" in output)
# now use its storage index to find the other shares using the
# 'find-shares' tool