Skip to content

Commit

Permalink
PeerAddress: add equalsIgnoringMetadata() method
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarguindzberg committed Apr 1, 2019
1 parent 26889a8 commit e06453c
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 @@ -314,6 +314,22 @@ public boolean equals(Object o) {

}

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 e06453c

Please sign in to comment.