If we compare IVs, they of course must properly implement the equals method

This fixes the bug where we would request objects again that were already stored.
This commit is contained in:
Christian Basler 2015-04-18 14:34:04 +02:00
parent ceae11b5c6
commit 2cd857dd36

View File

@ -21,6 +21,7 @@ import ch.dissem.bitmessage.utils.Strings;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
/**
* Created by chris on 13.03.15.
@ -31,6 +32,22 @@ public class InventoryVector implements Streamable {
*/
private final byte[] hash;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof InventoryVector)) return false;
InventoryVector that = (InventoryVector) o;
return Arrays.equals(hash, that.hash);
}
@Override
public int hashCode() {
return hash != null ? Arrays.hashCode(hash) : 0;
}
public byte[] getHash() {
return hash;
}