Package org.klomp.snark.v2
Class V2Util
java.lang.Object
org.klomp.snark.v2.V2Util
Merkle utilities
- Since:
- 0.9.71
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<MerkleHash> calculateMerklePieces(File f, int plen) static MerkleHashcalculateMerkleRoot(byte[] b) static MerkleHashstatic MerkleHashcalculateMerkleRoot(InputStream in, int plen) Warning: Will return bad value if plen is greater than the next power of two of the input sizestatic MerkleHashcalculateMerkleRoot(List<MerkleHash> pieces, int plen) static booleancheckMerkle(MerkleHash root, List<MerkleHash> pieces, int plen) static booleanisValidPieceLength(int plen) 16K min and power of two Storage.MAX_PIECE_SIZE is checked elsewhere but do it here also.static void
-
Field Details
-
MIN
public static final int MIN- See Also:
-
-
Constructor Details
-
V2Util
public V2Util()
-
-
Method Details
-
isValidPieceLength
public static boolean isValidPieceLength(int plen) 16K min and power of two Storage.MAX_PIECE_SIZE is checked elsewhere but do it here also. -
checkMerkle
- Parameters:
pieces- two minimumplen- piece length, 16K minimum, power of two
-
calculateMerkleRoot
- Parameters:
pieces- two minimumplen- piece length, 16K minimum, power of two
-
calculateMerkleRoot
- Returns:
- the root hash
- Throws:
IOException
-
calculateMerkleRoot
- Returns:
- the root hash
- Throws:
IOException
-
calculateMerkleRoot
Warning: Will return bad value if plen is greater than the next power of two of the input size- Parameters:
plen- piece length, will be rectified to next power of two 16K min- Returns:
- the root hash
- Throws:
IOException
-
calculateMerklePieces
- Parameters:
plen- will use only if smaller than file size- Returns:
- the piece hashes
- Throws:
IOException
-
main
- Throws:
Exception
-