Skip to content

Commit

Permalink
PeerAddress: add equalsIgnoringMetadata() method.
Browse files Browse the repository at this point in the history
Cherry pick 127e1ac
  • Loading branch information
oscarguindzberg committed May 16, 2020
1 parent d1e55d1 commit 321aa8a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions core/src/main/java/org/bitcoinj/core/PeerAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,22 @@ public boolean equals(Object o) {
return !(services != null ? !services.equals(that.services) : that.services != null);
}

public boolean equalsIgnoringMetadata(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

PeerAddress that = (PeerAddress) o;

if (port != that.port) return false;
// Don't compare the time field
// if (time != that.time) return false;
if (addr != null ? !addr.equals(that.addr) : that.addr != null) return false;
if (hostname != null ? !hostname.equals(that.hostname) : that.hostname != null) return false;
// Don't compare the services field
// return !(services != null ? !services.equals(that.services) : that.services != null);
return true;
}

@Override
public int hashCode() {
int result = addr != null ? addr.hashCode() : 0;
Expand Down

0 comments on commit 321aa8a

Please sign in to comment.