mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Add missing equals/hashcode to Offer
This commit is contained in:
parent
93531c76d0
commit
5fee4b0b66
3 changed files with 51 additions and 8 deletions
|
@ -443,4 +443,33 @@ public class Offer implements Serializable {
|
|||
return offerPayload.isUseReOpenAfterAutoClose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Offer offer = (Offer) o;
|
||||
|
||||
if (offerPayload != null ? !offerPayload.equals(offer.offerPayload) : offer.offerPayload != null) return false;
|
||||
if (state != offer.state) return false;
|
||||
return !(errorMessageProperty != null ? !errorMessageProperty.equals(offer.errorMessageProperty) : offer.errorMessageProperty != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = offerPayload != null ? offerPayload.hashCode() : 0;
|
||||
result = 31 * result + (state != null ? state.hashCode() : 0);
|
||||
result = 31 * result + (errorMessageProperty != null ? errorMessageProperty.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Offer{" +
|
||||
"offerPayload=" + offerPayload +
|
||||
", state=" + state +
|
||||
", errorMessageProperty=" + errorMessageProperty +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ import io.bisq.core.offer.OfferBookService;
|
|||
import io.bisq.core.trade.TradeManager;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Optional;
|
||||
|
@ -37,9 +36,8 @@ import java.util.stream.Collectors;
|
|||
* It also use OfferRepository.Listener as the lists items class and we don't want to get any dependency out of the
|
||||
* package for that.
|
||||
*/
|
||||
@Slf4j
|
||||
public class OfferBook {
|
||||
private static final Logger log = LoggerFactory.getLogger(OfferBook.class);
|
||||
|
||||
private final OfferBookService offerBookService;
|
||||
private final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
|
||||
|
||||
|
@ -58,7 +56,6 @@ public class OfferBook {
|
|||
OfferBookListItem offerBookListItem = new OfferBookListItem(offer);
|
||||
if (!offerBookListItems.contains(offerBookListItem)) {
|
||||
offerBookListItems.add(offerBookListItem);
|
||||
|
||||
Log.logIfStressTests("OfferPayload added: No. of offers = " + offerBookListItems.size());
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +98,7 @@ public class OfferBook {
|
|||
|
||||
Log.logIfStressTests("OfferPayload filled: No. of offers = " + offerBookListItems.size());
|
||||
|
||||
log.debug("offerBookListItems " + offerBookListItems.size());
|
||||
log.debug("offerBookListItems.size " + offerBookListItems.size());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
log.error("Error at fillOfferBookListItems: " + t.toString());
|
||||
|
|
|
@ -23,7 +23,6 @@ import io.bisq.common.crypto.Sig;
|
|||
import io.bisq.wire.crypto.Encryption;
|
||||
import io.bisq.wire.payload.Payload;
|
||||
import io.bisq.wire.proto.Messages;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
|
@ -36,12 +35,12 @@ import java.security.NoSuchProviderException;
|
|||
import java.security.PublicKey;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Same as KeyRing but with public keys only.
|
||||
* Used to send public keys over the wire to other peer.
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@Slf4j
|
||||
public final class PubKeyRing implements Payload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
|
@ -98,6 +97,24 @@ public final class PubKeyRing implements Payload {
|
|||
.setEncryptionPubKeyBytes(ByteString.copyFrom(encryptionPubKeyBytes)).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PubKeyRing that = (PubKeyRing) o;
|
||||
|
||||
if (!Arrays.equals(signaturePubKeyBytes, that.signaturePubKeyBytes)) return false;
|
||||
return Arrays.equals(encryptionPubKeyBytes, that.encryptionPubKeyBytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = signaturePubKeyBytes != null ? Arrays.hashCode(signaturePubKeyBytes) : 0;
|
||||
result = 31 * result + (encryptionPubKeyBytes != null ? Arrays.hashCode(encryptionPubKeyBytes) : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PubKeyRing{" +
|
||||
|
|
Loading…
Add table
Reference in a new issue