def _indexTable2data(self, pfx: Name, decoder, end: int): # traverse the manifest tree # input: decoder with index table # output: reassembled data data = b'' while decoder._offset < end: if decoder.peekType(NDN_TYPE_MANIFEST_DATAPTR, end): ptr = decoder.readBlobTlv(NDN_TYPE_MANIFEST_DATAPTR) # print("data ptr %s" % binascii.hexlify(ptr)) name = copy.copy(pfx).setDigest(ptr) # print(name.to_json()) chunk = self.icn.readChunk(name) data += NdnTlvEncoder().decode(chunk).get_bytes() elif decoder.peekType(NDN_TYPE_MANIFEST_MANIFESTPTR, end): ptr = decoder.readBlobTlv(NDN_TYPE_MANIFEST_MANIFESTPTR) # print("manifest ptr %s" % binascii.hexlify(ptr)) name = copy.copy(pfx).setDigest(ptr) chunk = self.icn.readChunk(name) content = NdnTlvEncoder().decode(chunk) data += self._manifestToBytes(content.get_bytes()) else: print("invalid index table entry") return data return data
def bytesFromManifestName(self, name: Name): chunk = self.icn.readChunk(name) content = NdnTlvEncoder().decode(chunk) name._components.pop() # drop the last component (e.g. '_') return self._manifestToBytes(name, content.get_bytes())