mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-19 18:00:39 +01:00
VarInt: implement equals()
and hashCode()
`originallyEncodedSize` is not considered on purpose, because it is only relevant for serialization.
This commit is contained in:
parent
2faaf9febc
commit
301c8e4a76
@ -21,6 +21,7 @@ import java.nio.BufferOverflowException;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.bitcoinj.base.internal.Preconditions.check;
|
||||
|
||||
@ -177,4 +178,17 @@ public class VarInt {
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
// originallyEncodedSize is not considered on purpose
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
return value == ((VarInt) o).value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(value);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user