Skip to content

Commit

Permalink
resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
phelps-sg committed Nov 8, 2020
2 parents ce95a43 + d963af2 commit da03b95
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion inputformat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ compileJava.options.encoding = 'UTF-8'

group = "com.mesonomics"
archivesBaseName = "hadoopcryptoledger-plus-fileformat"
version = "0.4-SNAPSHOT"
version = "0.4"

jar {
manifest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
**/
public class BitcoinBlock implements Serializable, Writable {

public static final int HEADER_SIZE_BYTES = 6*32;

private LittleEndianUInt32 blockSize;
private byte[] magicNo;
private LittleEndianUInt32 version;
Expand Down Expand Up @@ -274,8 +276,8 @@ public String getHashString() {
}

public byte[] getHeader() {
ByteArrayOutputStream header = new ByteArrayOutputStream();
try {
ByteArrayOutputStream header = new ByteArrayOutputStream();
header.write(version.getBytes());
header.write(hashPrevBlock);
header.write(BitcoinUtil.reverseByteArray(calculateMerkleRoot()));
Expand All @@ -284,7 +286,7 @@ public byte[] getHeader() {
header.write(nonce.getBytes());
return header.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e); // Should never happen
throw new RuntimeException(e); // Never happens
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

public class BitcoinUtil {

public static final MessageDigest digestPrototype = BitcoinUtil.SHA256digest();

private BitcoinUtil() {
}

Expand Down Expand Up @@ -339,6 +341,14 @@ public static byte[] hash(byte[] input) {
return digest.digest(input);
}

public static final MessageDigest newDigest() {
try {
return (MessageDigest) digestPrototype.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}

/**
* Returns a new SHA-256 MessageDigest instance.
*
Expand All @@ -347,7 +357,7 @@ public static byte[] hash(byte[] input) {
*
* @return a new SHA-256 MessageDigest instance
*/
public static MessageDigest newDigest() {
public static MessageDigest SHA256digest() {
try {
return MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
Expand Down

0 comments on commit da03b95

Please sign in to comment.