Fix merge issues

This commit is contained in:
chimp1984 2019-08-29 17:07:39 +02:00
parent 329572cc5d
commit 5d338e693c
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3
2 changed files with 50 additions and 51 deletions

View file

@ -65,12 +65,12 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
TRADE;
public static DisputeCommunicationMessage.Type fromProto(
proto.DisputeCommunicationMessage.Type type) {
protobuf.DisputeCommunicationMessage.Type type) {
return ProtoUtil.enumFromProto(DisputeCommunicationMessage.Type.class, type.name());
}
public static proto.DisputeCommunicationMessage.Type toProtoMessage(Type type) {
return proto.DisputeCommunicationMessage.Type.valueOf(type.name());
public static protobuf.DisputeCommunicationMessage.Type toProtoMessage(Type type) {
return protobuf.DisputeCommunicationMessage.Type.valueOf(type.name());
}
}
@ -160,10 +160,8 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
}
@Override
public proto.NetworkEnvelope toProtoNetworkEnvelope() {
proto.DisputeCommunicationMessage.Builder builder = proto.DisputeCommunicationMessage.newBuilder()
public proto.NetworkEnvelope toProtoNetworkEnvelope() {
proto.DisputeCommunicationMessage.Builder builder = proto.DisputeCommunicationMessage.newBuilder()
public protobuf.NetworkEnvelope toProtoNetworkEnvelope() {
protobuf.DisputeCommunicationMessage.Builder builder = protobuf.DisputeCommunicationMessage.newBuilder()
.setType(DisputeCommunicationMessage.Type.toProtoMessage(type))
.setTradeId(tradeId)
.setTraderId(traderId)
@ -184,33 +182,34 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
.build();
}
public static DisputeCommunicationMessage fromProto(protobuf.DisputeCommunicationMessage proto, int messageVersion) {
public static DisputeCommunicationMessage fromProto(protobuf.DisputeCommunicationMessage protobuf,
int messageVersion) {
final DisputeCommunicationMessage disputeCommunicationMessage = new DisputeCommunicationMessage(
DisputeCommunicationMessage.Type.fromProto(proto.getType()),
proto.getTradeId(),
proto.getTraderId(),
proto.getSenderIsTrader(),
proto.getMessage(),
new ArrayList<>(proto.getAttachmentsList().stream().map(Attachment::fromProto).collect(Collectors.toList())),
NodeAddress.fromProto(proto.getSenderNodeAddress()),
proto.getDate(),
proto.getArrived(),
proto.getStoredInMailbox(),
proto.getUid(),
DisputeCommunicationMessage.Type.fromProto(protobuf.getType()),
protobuf.getTradeId(),
protobuf.getTraderId(),
protobuf.getSenderIsTrader(),
protobuf.getMessage(),
new ArrayList<>(protobuf.getAttachmentsList().stream().map(Attachment::fromProto).collect(Collectors.toList())),
NodeAddress.fromProto(protobuf.getSenderNodeAddress()),
protobuf.getDate(),
protobuf.getArrived(),
protobuf.getStoredInMailbox(),
protobuf.getUid(),
messageVersion,
proto.getAcknowledged(),
proto.getSendMessageError().isEmpty() ? null : proto.getSendMessageError(),
proto.getAckError().isEmpty() ? null : proto.getAckError());
disputeCommunicationMessage.setSystemMessage(proto.getIsSystemMessage());
protobuf.getAcknowledged(),
protobuf.getSendMessageError().isEmpty() ? null : protobuf.getSendMessageError(),
protobuf.getAckError().isEmpty() ? null : protobuf.getAckError());
disputeCommunicationMessage.setSystemMessage(protobuf.getIsSystemMessage());
return disputeCommunicationMessage;
}
public static DisputeCommunicationMessage fromPayloadProto(protobuf.DisputeCommunicationMessage proto) {
public static DisputeCommunicationMessage fromPayloadProto(protobuf.DisputeCommunicationMessage protobuf) {
// We have the case that an envelope got wrapped into a payload.
// We don't check the message version here as it was checked in the carrier envelope already (in connection class)
// Payloads don't have a message version and are also used for persistence
// We set the value to -1 to indicate it is set but irrelevant
return fromProto(proto, -1);
return fromProto(protobuf, -1);
}

View file

@ -434,9 +434,9 @@ public abstract class Trade implements Tradable, Model {
.setProcessModel(processModel.toProtoMessage())
.setTradeAmountAsLong(tradeAmountAsLong)
.setTradePrice(tradePrice)
.setState(proto.Trade.State.valueOf(state.name()))
.setDisputeState(proto.Trade.DisputeState.valueOf(disputeState.name()))
.setTradePeriodState(proto.Trade.TradePeriodState.valueOf(tradePeriodState.name()))
.setState(protobuf.Trade.State.valueOf(state.name()))
.setDisputeState(protobuf.Trade.DisputeState.valueOf(disputeState.name()))
.setTradePeriodState(protobuf.Trade.TradePeriodState.valueOf(tradePeriodState.name()))
.addAllCommunicationMessages(communicationMessages.stream()
.map(msg -> msg.toProtoNetworkEnvelope().getDisputeCommunicationMessage())
.collect(Collectors.toList()));
@ -461,30 +461,30 @@ public abstract class Trade implements Tradable, Model {
return builder.build();
}
public static Trade fromProto(Trade trade, protobuf.Trade proto, CoreProtoResolver coreProtoResolver) {
trade.setTakeOfferDate(proto.getTakeOfferDate());
trade.setProcessModel(ProcessModel.fromProto(proto.getProcessModel(), coreProtoResolver));
trade.setState(State.fromProto(proto.getState()));
trade.setDisputeState(DisputeState.fromProto(proto.getDisputeState()));
trade.setTradePeriodState(TradePeriodState.fromProto(proto.getTradePeriodState()));
trade.setTakerFeeTxId(ProtoUtil.stringOrNullFromProto(proto.getTakerFeeTxId()));
trade.setDepositTxId(ProtoUtil.stringOrNullFromProto(proto.getDepositTxId()));
trade.setPayoutTxId(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxId()));
trade.setContract(proto.hasContract() ? Contract.fromProto(proto.getContract(), coreProtoResolver) : null);
trade.setContractAsJson(ProtoUtil.stringOrNullFromProto(proto.getContractAsJson()));
trade.setContractHash(ProtoUtil.byteArrayOrNullFromProto(proto.getContractHash()));
trade.setTakerContractSignature(ProtoUtil.stringOrNullFromProto(proto.getTakerContractSignature()));
trade.setMakerContractSignature(ProtoUtil.stringOrNullFromProto(proto.getMakerContractSignature()));
trade.setArbitratorNodeAddress(proto.hasArbitratorNodeAddress() ? NodeAddress.fromProto(proto.getArbitratorNodeAddress()) : null);
trade.setMediatorNodeAddress(proto.hasMediatorNodeAddress() ? NodeAddress.fromProto(proto.getMediatorNodeAddress()) : null);
trade.setArbitratorBtcPubKey(ProtoUtil.byteArrayOrNullFromProto(proto.getArbitratorBtcPubKey()));
trade.setTakerPaymentAccountId(ProtoUtil.stringOrNullFromProto(proto.getTakerPaymentAccountId()));
trade.setErrorMessage(ProtoUtil.stringOrNullFromProto(proto.getErrorMessage()));
trade.setArbitratorPubKeyRing(proto.hasArbitratorPubKeyRing() ? PubKeyRing.fromProto(proto.getArbitratorPubKeyRing()) : null);
trade.setMediatorPubKeyRing(proto.hasMediatorPubKeyRing() ? PubKeyRing.fromProto(proto.getMediatorPubKeyRing()) : null);
trade.setCounterCurrencyTxId(proto.getCounterCurrencyTxId().isEmpty() ? null : proto.getCounterCurrencyTxId());
public static Trade fromProto(Trade trade, protobuf.Trade protobuf, CoreProtoResolver coreProtoResolver) {
trade.setTakeOfferDate(protobuf.getTakeOfferDate());
trade.setProcessModel(ProcessModel.fromProto(protobuf.getProcessModel(), coreProtoResolver));
trade.setState(State.fromProto(protobuf.getState()));
trade.setDisputeState(DisputeState.fromProto(protobuf.getDisputeState()));
trade.setTradePeriodState(TradePeriodState.fromProto(protobuf.getTradePeriodState()));
trade.setTakerFeeTxId(ProtoUtil.stringOrNullFromProto(protobuf.getTakerFeeTxId()));
trade.setDepositTxId(ProtoUtil.stringOrNullFromProto(protobuf.getDepositTxId()));
trade.setPayoutTxId(ProtoUtil.stringOrNullFromProto(protobuf.getPayoutTxId()));
trade.setContract(protobuf.hasContract() ? Contract.fromProto(protobuf.getContract(), coreProtoResolver) : null);
trade.setContractAsJson(ProtoUtil.stringOrNullFromProto(protobuf.getContractAsJson()));
trade.setContractHash(ProtoUtil.byteArrayOrNullFromProto(protobuf.getContractHash()));
trade.setTakerContractSignature(ProtoUtil.stringOrNullFromProto(protobuf.getTakerContractSignature()));
trade.setMakerContractSignature(ProtoUtil.stringOrNullFromProto(protobuf.getMakerContractSignature()));
trade.setArbitratorNodeAddress(protobuf.hasArbitratorNodeAddress() ? NodeAddress.fromProto(protobuf.getArbitratorNodeAddress()) : null);
trade.setMediatorNodeAddress(protobuf.hasMediatorNodeAddress() ? NodeAddress.fromProto(protobuf.getMediatorNodeAddress()) : null);
trade.setArbitratorBtcPubKey(ProtoUtil.byteArrayOrNullFromProto(protobuf.getArbitratorBtcPubKey()));
trade.setTakerPaymentAccountId(ProtoUtil.stringOrNullFromProto(protobuf.getTakerPaymentAccountId()));
trade.setErrorMessage(ProtoUtil.stringOrNullFromProto(protobuf.getErrorMessage()));
trade.setArbitratorPubKeyRing(protobuf.hasArbitratorPubKeyRing() ? PubKeyRing.fromProto(protobuf.getArbitratorPubKeyRing()) : null);
trade.setMediatorPubKeyRing(protobuf.hasMediatorPubKeyRing() ? PubKeyRing.fromProto(protobuf.getMediatorPubKeyRing()) : null);
trade.setCounterCurrencyTxId(protobuf.getCounterCurrencyTxId().isEmpty() ? null : protobuf.getCounterCurrencyTxId());
trade.communicationMessages.addAll(proto.getCommunicationMessagesList().stream()
trade.communicationMessages.addAll(protobuf.getCommunicationMessagesList().stream()
.map(DisputeCommunicationMessage::fromPayloadProto)
.collect(Collectors.toList()));