MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / verifyPiece

Method verifyPiece

plugins/Bigfile/BigfilePlugin.py:342–347  ·  view source on GitHub ↗
(self, inner_path, pos, piece)

Source from the content-addressed store, hash-verified

340 return piecemap
341
342 def verifyPiece(self, inner_path, pos, piece):
343 piecemap = self.getPiecemap(inner_path)
344 piece_i = int(pos / piecemap["piece_size"])
345 if CryptHash.sha512sum(piece, format="digest") != piecemap["sha512_pieces"][piece_i]:
346 raise VerifyError("Invalid hash")
347 return True
348
349 def verifyFile(self, inner_path, file, ignore_same=True):
350 if "|" not in inner_path:

Callers 3

verifyFileMethod · 0.95
testVerifyPieceMethod · 0.80
testRangedFileRequestMethod · 0.80

Calls 2

getPiecemapMethod · 0.95
VerifyErrorClass · 0.90

Tested by 2

testVerifyPieceMethod · 0.64
testRangedFileRequestMethod · 0.64