mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 10:45:51 +00:00
Sha256Hash: use Guava to pack the hash code instead of hand written code.
This commit is contained in:
parent
6aa4e51de6
commit
75b952d1c7
@ -18,6 +18,7 @@
|
|||||||
package org.bitcoinj.core;
|
package org.bitcoinj.core;
|
||||||
|
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
import com.google.common.primitives.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -115,7 +116,7 @@ public class Sha256Hash implements Serializable, Comparable<Sha256Hash> {
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
// Use the last 4 bytes, not the first 4 which are often zeros in Bitcoin.
|
// Use the last 4 bytes, not the first 4 which are often zeros in Bitcoin.
|
||||||
return (bytes[31] & 0xFF) | ((bytes[30] & 0xFF) << 8) | ((bytes[29] & 0xFF) << 16) | ((bytes[28] & 0xFF) << 24);
|
return Ints.fromBytes(bytes[28], bytes[29], bytes[30], bytes[31]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user