BlockLocator: functional-style hashCode() calculation

Use mapToInt/reduce.
This commit is contained in:
Sean Gilligan 2023-08-07 19:03:44 -07:00 committed by Andreas Schildbach
parent e34dd300ec
commit 690f5149c0

View file

@ -98,11 +98,9 @@ public final class BlockLocator {
@Override
public int hashCode() {
int hashCode = 0;
for (Sha256Hash i : hashes) {
hashCode ^= i.hashCode();
}
return hashCode;
return hashes.stream()
.mapToInt(Sha256Hash::hashCode)
.reduce(0, (a, b) -> a ^ b);
}
@Override