Skip to content

Commit

Permalink
Override Object methods in Federation. Make equals method different i…
Browse files Browse the repository at this point in the history
…n StandardMultisig and ErpFederation to be consistent with hashCode
  • Loading branch information
julia-zack committed Sep 30, 2023
1 parent d32cd4f commit f880a8d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
14 changes: 14 additions & 0 deletions rskj-core/src/main/java/co/rsk/peg/ErpFederation.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ public int getNumberOfSignaturesRequired() {
return Integer.parseInt(thresholdChunk.toString());
}

@Override
public boolean equals(Object other){
if (this == other) {
return true;
}

if (other == null || this.getClass() != other.getClass()) {
return false;
}

ErpFederation otherFederation = (ErpFederation) other;
return this.getAddress() == otherFederation.getAddress();
}

@Override
public int hashCode() {
// Can use java.util.Objects.hash since all of Instant, int and List<BtcECKey> have
Expand Down
15 changes: 3 additions & 12 deletions rskj-core/src/main/java/co/rsk/peg/Federation.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,9 @@ public String toString() {
return String.format("Got federation with address %s", getAddress());
}

public boolean equals(Object other){
if (this == other) {
return true;
}

if (other == null || this.getClass() != other.getClass()) {
return false;
}

Federation otherFederation = (Federation) other;
return this.getAddress() == otherFederation.getAddress();
}
@Override
public abstract boolean equals(Object other);

@Override
public abstract int hashCode();
}
14 changes: 14 additions & 0 deletions rskj-core/src/main/java/co/rsk/peg/StandardMultisigFederation.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ public int getNumberOfSignaturesRequired() {
return Integer.parseInt(thresholdChunk.toString());
}

@Override
public boolean equals(Object other){
if (this == other) {
return true;
}

if (other == null || this.getClass() != other.getClass()) {
return false;
}

StandardMultisigFederation otherFederation = (StandardMultisigFederation) other;
return this.getAddress() == otherFederation.getAddress();
}

@Override
public int hashCode() {
// Can use java.util.Objects.hash since all of Instant, int and List<BtcECKey> have
Expand Down

0 comments on commit f880a8d

Please sign in to comment.