3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 02:35:52 +00:00

TransactionOutput: take parent hash and index into account in the hashcode. Inserting TransactionOutput's with identical scripts/values but different outpoints into a hashset will work properly now.

This commit is contained in:
Mike Hearn 2015-03-10 17:03:21 -07:00
parent c0297f2c12
commit 821de89e69

View File

@ -461,6 +461,10 @@ public class TransactionOutput extends ChildMessage implements Serializable {
@Override
public int hashCode() {
return 31 * (int) value + (scriptBytes != null ? Arrays.hashCode(scriptBytes) : 0);
int result = (int) (value ^ (value >>> 32));
result = 31 * result + Arrays.hashCode(scriptBytes);
if (parent != null)
result *= parent.getHash().hashCode() + getIndex();
return result;
}
}