mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
Remove storage from dispute. We do persistence from outside now.
Impl. PersistablePayload Make openingDate final and contr param
This commit is contained in:
parent
8f38de30e9
commit
158b7a92f9
1 changed files with 16 additions and 79 deletions
|
@ -25,7 +25,7 @@ import bisq.core.trade.Contract;
|
||||||
import bisq.common.crypto.PubKeyRing;
|
import bisq.common.crypto.PubKeyRing;
|
||||||
import bisq.common.proto.ProtoUtil;
|
import bisq.common.proto.ProtoUtil;
|
||||||
import bisq.common.proto.network.NetworkPayload;
|
import bisq.common.proto.network.NetworkPayload;
|
||||||
import bisq.common.storage.Storage;
|
import bisq.common.proto.persistable.PersistablePayload;
|
||||||
import bisq.common.util.Utilities;
|
import bisq.common.util.Utilities;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
|
@ -57,7 +57,7 @@ import javax.annotation.Nullable;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@Getter
|
@Getter
|
||||||
public final class Dispute implements NetworkPayload {
|
public final class Dispute implements NetworkPayload, PersistablePayload {
|
||||||
private final String tradeId;
|
private final String tradeId;
|
||||||
private final String id;
|
private final String id;
|
||||||
private final int traderId;
|
private final int traderId;
|
||||||
|
@ -85,15 +85,14 @@ public final class Dispute implements NetworkPayload {
|
||||||
private final PubKeyRing agentPubKeyRing; // dispute agent
|
private final PubKeyRing agentPubKeyRing; // dispute agent
|
||||||
private final boolean isSupportTicket;
|
private final boolean isSupportTicket;
|
||||||
private final ObservableList<ChatMessage> chatMessages = FXCollections.observableArrayList();
|
private final ObservableList<ChatMessage> chatMessages = FXCollections.observableArrayList();
|
||||||
private BooleanProperty isClosedProperty = new SimpleBooleanProperty();
|
private final BooleanProperty isClosedProperty = new SimpleBooleanProperty();
|
||||||
// disputeResultProperty.get is Nullable!
|
// disputeResultProperty.get is Nullable!
|
||||||
private ObjectProperty<DisputeResult> disputeResultProperty = new SimpleObjectProperty<>();
|
private final ObjectProperty<DisputeResult> disputeResultProperty = new SimpleObjectProperty<>();
|
||||||
|
private final long openingDate;
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Setter
|
||||||
private String disputePayoutTxId;
|
private String disputePayoutTxId;
|
||||||
private long openingDate;
|
@Setter
|
||||||
|
|
||||||
transient private Storage<? extends DisputeList> storage;
|
|
||||||
|
|
||||||
// Added v1.2.0
|
// Added v1.2.0
|
||||||
private SupportType supportType;
|
private SupportType supportType;
|
||||||
// Only used at refundAgent so that he knows how the mediator resolved the case
|
// Only used at refundAgent so that he knows how the mediator resolved the case
|
||||||
|
@ -118,7 +117,7 @@ public final class Dispute implements NetworkPayload {
|
||||||
// Constructor
|
// Constructor
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public Dispute(Storage<? extends DisputeList> storage,
|
public Dispute(long openingDate,
|
||||||
String tradeId,
|
String tradeId,
|
||||||
int traderId,
|
int traderId,
|
||||||
boolean disputeOpenerIsBuyer,
|
boolean disputeOpenerIsBuyer,
|
||||||
|
@ -137,51 +136,7 @@ public final class Dispute implements NetworkPayload {
|
||||||
PubKeyRing agentPubKeyRing,
|
PubKeyRing agentPubKeyRing,
|
||||||
boolean isSupportTicket,
|
boolean isSupportTicket,
|
||||||
SupportType supportType) {
|
SupportType supportType) {
|
||||||
this(tradeId,
|
this.openingDate = openingDate;
|
||||||
traderId,
|
|
||||||
disputeOpenerIsBuyer,
|
|
||||||
disputeOpenerIsMaker,
|
|
||||||
traderPubKeyRing,
|
|
||||||
tradeDate,
|
|
||||||
contract,
|
|
||||||
contractHash,
|
|
||||||
depositTxSerialized,
|
|
||||||
payoutTxSerialized,
|
|
||||||
depositTxId,
|
|
||||||
payoutTxId,
|
|
||||||
contractAsJson,
|
|
||||||
makerContractSignature,
|
|
||||||
takerContractSignature,
|
|
||||||
agentPubKeyRing,
|
|
||||||
isSupportTicket,
|
|
||||||
supportType);
|
|
||||||
this.storage = storage;
|
|
||||||
openingDate = new Date().getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PROTO BUFFER
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public Dispute(String tradeId,
|
|
||||||
int traderId,
|
|
||||||
boolean disputeOpenerIsBuyer,
|
|
||||||
boolean disputeOpenerIsMaker,
|
|
||||||
PubKeyRing traderPubKeyRing,
|
|
||||||
long tradeDate,
|
|
||||||
Contract contract,
|
|
||||||
@Nullable byte[] contractHash,
|
|
||||||
@Nullable byte[] depositTxSerialized,
|
|
||||||
@Nullable byte[] payoutTxSerialized,
|
|
||||||
@Nullable String depositTxId,
|
|
||||||
@Nullable String payoutTxId,
|
|
||||||
String contractAsJson,
|
|
||||||
@Nullable String makerContractSignature,
|
|
||||||
@Nullable String takerContractSignature,
|
|
||||||
PubKeyRing agentPubKeyRing,
|
|
||||||
boolean isSupportTicket,
|
|
||||||
SupportType supportType) {
|
|
||||||
this.tradeId = tradeId;
|
this.tradeId = tradeId;
|
||||||
this.traderId = traderId;
|
this.traderId = traderId;
|
||||||
this.disputeOpenerIsBuyer = disputeOpenerIsBuyer;
|
this.disputeOpenerIsBuyer = disputeOpenerIsBuyer;
|
||||||
|
@ -205,6 +160,11 @@ public final class Dispute implements NetworkPayload {
|
||||||
uid = UUID.randomUUID().toString();
|
uid = UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PROTO BUFFER
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public protobuf.Dispute toProtoMessage() {
|
public protobuf.Dispute toProtoMessage() {
|
||||||
// Needed to avoid ConcurrentModificationException
|
// Needed to avoid ConcurrentModificationException
|
||||||
|
@ -244,7 +204,8 @@ public final class Dispute implements NetworkPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dispute fromProto(protobuf.Dispute proto, CoreProtoResolver coreProtoResolver) {
|
public static Dispute fromProto(protobuf.Dispute proto, CoreProtoResolver coreProtoResolver) {
|
||||||
Dispute dispute = new Dispute(proto.getTradeId(),
|
Dispute dispute = new Dispute(proto.getOpeningDate(),
|
||||||
|
proto.getTradeId(),
|
||||||
proto.getTraderId(),
|
proto.getTraderId(),
|
||||||
proto.getDisputeOpenerIsBuyer(),
|
proto.getDisputeOpenerIsBuyer(),
|
||||||
proto.getDisputeOpenerIsMaker(),
|
proto.getDisputeOpenerIsMaker(),
|
||||||
|
@ -267,7 +228,6 @@ public final class Dispute implements NetworkPayload {
|
||||||
.map(ChatMessage::fromPayloadProto)
|
.map(ChatMessage::fromPayloadProto)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
dispute.openingDate = proto.getOpeningDate();
|
|
||||||
dispute.isClosedProperty.set(proto.getIsClosed());
|
dispute.isClosedProperty.set(proto.getIsClosed());
|
||||||
if (proto.hasDisputeResult())
|
if (proto.hasDisputeResult())
|
||||||
dispute.disputeResultProperty.set(DisputeResult.fromProto(proto.getDisputeResult()));
|
dispute.disputeResultProperty.set(DisputeResult.fromProto(proto.getDisputeResult()));
|
||||||
|
@ -299,7 +259,6 @@ public final class Dispute implements NetworkPayload {
|
||||||
public void addAndPersistChatMessage(ChatMessage chatMessage) {
|
public void addAndPersistChatMessage(ChatMessage chatMessage) {
|
||||||
if (!chatMessages.contains(chatMessage)) {
|
if (!chatMessages.contains(chatMessage)) {
|
||||||
chatMessages.add(chatMessage);
|
chatMessages.add(chatMessage);
|
||||||
storage.queueUpForSave();
|
|
||||||
} else {
|
} else {
|
||||||
log.error("disputeDirectMessage already exists");
|
log.error("disputeDirectMessage already exists");
|
||||||
}
|
}
|
||||||
|
@ -310,35 +269,14 @@ public final class Dispute implements NetworkPayload {
|
||||||
// Setters
|
// Setters
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// In case we get the object via the network storage is not set as its transient, so we need to set it.
|
|
||||||
public void setStorage(Storage<? extends DisputeList> storage) {
|
|
||||||
this.storage = storage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsClosed(boolean isClosed) {
|
public void setIsClosed(boolean isClosed) {
|
||||||
boolean changed = this.isClosedProperty.get() != isClosed;
|
|
||||||
this.isClosedProperty.set(isClosed);
|
this.isClosedProperty.set(isClosed);
|
||||||
if (changed)
|
|
||||||
storage.queueUpForSave();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisputeResult(DisputeResult disputeResult) {
|
public void setDisputeResult(DisputeResult disputeResult) {
|
||||||
boolean changed = disputeResultProperty.get() == null || !disputeResultProperty.get().equals(disputeResult);
|
|
||||||
disputeResultProperty.set(disputeResult);
|
disputeResultProperty.set(disputeResult);
|
||||||
if (changed)
|
|
||||||
storage.queueUpForSave();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisputePayoutTxId(String disputePayoutTxId) {
|
|
||||||
boolean changed = this.disputePayoutTxId == null || !this.disputePayoutTxId.equals(disputePayoutTxId);
|
|
||||||
this.disputePayoutTxId = disputePayoutTxId;
|
|
||||||
if (changed)
|
|
||||||
storage.queueUpForSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupportType(SupportType supportType) {
|
|
||||||
this.supportType = supportType;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -396,7 +334,6 @@ public final class Dispute implements NetworkPayload {
|
||||||
",\n disputeResultProperty=" + disputeResultProperty +
|
",\n disputeResultProperty=" + disputeResultProperty +
|
||||||
",\n disputePayoutTxId='" + disputePayoutTxId + '\'' +
|
",\n disputePayoutTxId='" + disputePayoutTxId + '\'' +
|
||||||
",\n openingDate=" + openingDate +
|
",\n openingDate=" + openingDate +
|
||||||
",\n storage=" + storage +
|
|
||||||
",\n supportType=" + supportType +
|
",\n supportType=" + supportType +
|
||||||
",\n mediatorsDisputeResult='" + mediatorsDisputeResult + '\'' +
|
",\n mediatorsDisputeResult='" + mediatorsDisputeResult + '\'' +
|
||||||
",\n delayedPayoutTxId='" + delayedPayoutTxId + '\'' +
|
",\n delayedPayoutTxId='" + delayedPayoutTxId + '\'' +
|
||||||
|
|
Loading…
Add table
Reference in a new issue