def verifyPiece(self, inner_path, pos, piece): try: piecemap = self.getPiecemap(inner_path) except OSError as err: raise VerifyError("Unable to download piecemap: %s" % err) piece_i = int(pos / piecemap["piece_size"]) if CryptHash.sha512sum( piece, format="digest") != piecemap["sha512_pieces"][piece_i]: raise VerifyError("Invalid hash") return True
def verifyPiece(self, inner_path, pos, piece): piecemap = self.getPiecemap(inner_path) piece_i = pos / piecemap["piece_size"] if CryptHash.sha512sum( piece, format="digest") != piecemap["sha512_pieces"][piece_i]: raise VerifyError("Invalid hash") return True