Rename myNodeAddress to senderNodeAddress to be compatible with interface methods and Lombok getter.

This commit is contained in:
Manfred Karrer 2017-05-12 18:58:58 +02:00
parent aee2f8ecac
commit 918a8f2115
9 changed files with 55 additions and 61 deletions

View File

@ -248,7 +248,7 @@ message PayoutTxPublishedMessage {
message PeerPublishedPayoutTxMessage {
bytes transaction = 1;
string trade_id = 2;
NodeAddress my_node_address = 3;
NodeAddress sender_node_address = 3;
string uid = 4;
}
@ -257,13 +257,13 @@ message PeerPublishedPayoutTxMessage {
message OpenNewDisputeMessage {
Dispute dispute = 1;
NodeAddress my_node_address = 2;
NodeAddress sender_node_address = 2;
string uid = 3;
}
message PeerOpenedDisputeMessage {
Dispute dispute = 1;
NodeAddress my_node_address = 2;
NodeAddress sender_node_address = 2;
string uid = 3;
}
@ -277,21 +277,21 @@ message DisputeCommunicationMessage {
bool arrived = 7;
bool stored_in_mailbox = 8;
bool is_system_message = 9;
NodeAddress my_node_address = 10;
NodeAddress sender_node_address = 10;
string uid = 11;
}
message DisputeResultMessage {
string uid = 1;
DisputeResult dispute_result = 2;
NodeAddress my_node_address = 3;
NodeAddress sender_node_address = 3;
}
message PrivateNotificationMessage {
int32 message_version = 1;
string uid = 2;
NodeAddress my_node_address = 3;
NodeAddress sender_node_address = 3;
PrivateNotificationPayload private_notification_payload = 4;
}

View File

@ -11,15 +11,15 @@ import lombok.extern.slf4j.Slf4j;
@Value
@Slf4j
public class PrivateNotificationMessage implements MailboxMessage {
private final NodeAddress myNodeAddress;
private final NodeAddress senderNodeAddress;
private final PrivateNotificationPayload privateNotificationPayload;
private final String uid;
private final int messageVersion = Version.getP2PMessageVersion();
public PrivateNotificationMessage(PrivateNotificationPayload privateNotificationPayload,
NodeAddress myNodeAddress,
NodeAddress senderNodeAddress,
String uid) {
this.myNodeAddress = myNodeAddress;
this.senderNodeAddress = senderNodeAddress;
this.privateNotificationPayload = privateNotificationPayload;
this.uid = uid;
}
@ -30,7 +30,7 @@ public class PrivateNotificationMessage implements MailboxMessage {
public static NetworkEnvelope fromProto(PB.PrivateNotificationMessage proto) {
return new PrivateNotificationMessage(PrivateNotificationPayload.fromProto(proto.getPrivateNotificationPayload()),
NodeAddress.fromProto(proto.getMyNodeAddress()),
NodeAddress.fromProto(proto.getSenderNodeAddress()),
proto.getUid());
}
@ -40,14 +40,14 @@ public class PrivateNotificationMessage implements MailboxMessage {
return msgBuilder.setPrivateNotificationMessage(msgBuilder.getPrivateNotificationMessageBuilder()
.setMessageVersion(messageVersion)
.setUid(uid)
.setMyNodeAddress(myNodeAddress.toProtoMessage())
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
.setPrivateNotificationPayload(privateNotificationPayload.toProtoMessage())).build();
}
@Override
public NodeAddress getSenderNodeAddress() {
return myNodeAddress;
return senderNodeAddress;
}
@Override

View File

@ -48,7 +48,7 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
private final int traderId;
private final boolean senderIsTrader;
private final String message;
private final NodeAddress myNodeAddress;
private final NodeAddress senderNodeAddress;
@Nullable
private final ArrayList<Attachment> attachments = new ArrayList<>();
private boolean arrived;
@ -65,7 +65,7 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
boolean senderIsTrader,
String message,
@Nullable List<Attachment> attachments,
NodeAddress myNodeAddress,
NodeAddress senderNodeAddress,
long date,
boolean arrived,
boolean storedInMailbox,
@ -75,7 +75,7 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
this.traderId = traderId;
this.senderIsTrader = senderIsTrader;
this.message = message;
this.myNodeAddress = myNodeAddress;
this.senderNodeAddress = senderNodeAddress;
this.date = date;
this.arrived = arrived;
this.storedInMailbox = storedInMailbox;
@ -99,7 +99,7 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
@Override
public NodeAddress getSenderNodeAddress() {
return myNodeAddress;
return senderNodeAddress;
}
public void addAttachment(Attachment attachment) {
@ -141,6 +141,6 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
.setArrived(arrived)
.setStoredInMailbox(storedInMailbox)
.setIsSystemMessage(isSystemMessage)
.setMyNodeAddress(myNodeAddress.toProtoMessage())).build();
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())).build();
}
}

View File

@ -29,17 +29,17 @@ import lombok.ToString;
public final class DisputeResultMessage extends DisputeMessage {
public final DisputeResult disputeResult;
private final NodeAddress myNodeAddress;
private final NodeAddress senderNodeAddress;
public DisputeResultMessage(DisputeResult disputeResult, NodeAddress myNodeAddress, String uid) {
public DisputeResultMessage(DisputeResult disputeResult, NodeAddress senderNodeAddress, String uid) {
super(uid);
this.disputeResult = disputeResult;
this.myNodeAddress = myNodeAddress;
this.senderNodeAddress = senderNodeAddress;
}
@Override
public NodeAddress getSenderNodeAddress() {
return myNodeAddress;
return senderNodeAddress;
}
@Override
@ -47,7 +47,7 @@ public final class DisputeResultMessage extends DisputeMessage {
PB.NetworkEnvelope.Builder msgBuilder = NetworkEnvelope.getDefaultBuilder();
return msgBuilder.setDisputeResultMessage(PB.DisputeResultMessage.newBuilder()
.setDisputeResult(disputeResult.toProtoMessage())
.setMyNodeAddress(myNodeAddress.toProtoMessage())
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
.setUid(getUid()))
.build();
}

View File

@ -29,23 +29,23 @@ import lombok.ToString;
public final class OpenNewDisputeMessage extends DisputeMessage {
public final Dispute dispute;
private final NodeAddress myNodeAddress;
private final NodeAddress senderNodeAddress;
public OpenNewDisputeMessage(Dispute dispute, NodeAddress myNodeAddress, String uid) {
public OpenNewDisputeMessage(Dispute dispute, NodeAddress senderNodeAddress, String uid) {
super(uid);
this.dispute = dispute;
this.myNodeAddress = myNodeAddress;
this.senderNodeAddress = senderNodeAddress;
}
@Override
public NodeAddress getSenderNodeAddress() {
return myNodeAddress;
return senderNodeAddress;
}
@Override
public PB.NetworkEnvelope toProtoNetworkEnvelope() {
PB.NetworkEnvelope.Builder msgBuilder = NetworkEnvelope.getDefaultBuilder();
return msgBuilder.setOpenNewDisputeMessage(PB.OpenNewDisputeMessage.newBuilder()
.setDispute(dispute.toProtoMessage()).setMyNodeAddress(myNodeAddress.toProtoMessage()).setUid(getUid())).build();
.setDispute(dispute.toProtoMessage()).setSenderNodeAddress(senderNodeAddress.toProtoMessage()).setUid(getUid())).build();
}
}

View File

@ -28,17 +28,17 @@ import lombok.ToString;
@ToString
public final class PeerOpenedDisputeMessage extends DisputeMessage {
public final Dispute dispute;
private final NodeAddress myNodeAddress;
private final NodeAddress senderNodeAddress;
public PeerOpenedDisputeMessage(Dispute dispute, NodeAddress myNodeAddress, String uid) {
public PeerOpenedDisputeMessage(Dispute dispute, NodeAddress senderNodeAddress, String uid) {
super(uid);
this.dispute = dispute;
this.myNodeAddress = myNodeAddress;
this.senderNodeAddress = senderNodeAddress;
}
@Override
public NodeAddress getSenderNodeAddress() {
return myNodeAddress;
return senderNodeAddress;
}
@Override
@ -46,7 +46,7 @@ public final class PeerOpenedDisputeMessage extends DisputeMessage {
PB.NetworkEnvelope.Builder msgBuilder = NetworkEnvelope.getDefaultBuilder();
return msgBuilder.setPeerOpenedDisputeMessage(PB.PeerOpenedDisputeMessage.newBuilder()
.setDispute(dispute.toProtoMessage())
.setMyNodeAddress(myNodeAddress.toProtoMessage())
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
.setUid(getUid())).build();
}
}

View File

@ -28,18 +28,18 @@ public final class PeerPublishedPayoutTxMessage extends DisputeMessage {
public final byte[] transaction;
public final String tradeId;
private final NodeAddress myNodeAddress;
private final NodeAddress senderNodeAddress;
public PeerPublishedPayoutTxMessage(byte[] transaction, String tradeId, NodeAddress myNodeAddress, String uid) {
public PeerPublishedPayoutTxMessage(byte[] transaction, String tradeId, NodeAddress senderNodeAddress, String uid) {
super(uid);
this.transaction = transaction;
this.tradeId = tradeId;
this.myNodeAddress = myNodeAddress;
this.senderNodeAddress = senderNodeAddress;
}
@Override
public NodeAddress getSenderNodeAddress() {
return myNodeAddress;
return senderNodeAddress;
}
@Override
@ -48,7 +48,7 @@ public final class PeerPublishedPayoutTxMessage extends DisputeMessage {
return msgBuilder.setPeerPublishedPayoutTxMessage(PB.PeerPublishedPayoutTxMessage.newBuilder()
.setTransaction(ByteString.copyFrom(transaction))
.setTradeId(tradeId)
.setMyNodeAddress(myNodeAddress.toProtoMessage())).build();
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())).build();
}
// transaction not displayed for privacy reasons...
@ -57,7 +57,7 @@ public final class PeerPublishedPayoutTxMessage extends DisputeMessage {
return "PeerPublishedPayoutTxMessage{" +
"transaction not displayed for privacy reasons..." +
", tradeId='" + tradeId + '\'' +
", myNodeAddress=" + myNodeAddress +
", senderNodeAddress=" + senderNodeAddress +
"} " + super.toString();
}
}

View File

@ -282,7 +282,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
private static NetworkEnvelope getPeerPublishedPayoutTxMessage(PB.PeerPublishedPayoutTxMessage peerPublishedPayoutTxMessage) {
return new PeerPublishedPayoutTxMessage(peerPublishedPayoutTxMessage.getTransaction().toByteArray(),
peerPublishedPayoutTxMessage.getTradeId(),
NodeAddress.fromProto(peerPublishedPayoutTxMessage.getMyNodeAddress()),
NodeAddress.fromProto(peerPublishedPayoutTxMessage.getSenderNodeAddress()),
peerPublishedPayoutTxMessage.getUid());
}
@ -300,18 +300,18 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
disputeResultproto.getArbitratorPubKey().toByteArray(), disputeResultproto.getCloseDate(),
disputeResultproto.getIsLoserPublisher());
return new DisputeResultMessage(disputeResult,
NodeAddress.fromProto(disputeResultMessage.getMyNodeAddress()),
NodeAddress.fromProto(disputeResultMessage.getSenderNodeAddress()),
disputeResultMessage.getUid());
}
private static NetworkEnvelope getPeerOpenedDisputeMessage(PB.PeerOpenedDisputeMessage peerOpenedDisputeMessage) {
return new PeerOpenedDisputeMessage(ProtoUtil.getDispute(peerOpenedDisputeMessage.getDispute()),
NodeAddress.fromProto(peerOpenedDisputeMessage.getMyNodeAddress()), peerOpenedDisputeMessage.getUid());
NodeAddress.fromProto(peerOpenedDisputeMessage.getSenderNodeAddress()), peerOpenedDisputeMessage.getUid());
}
private static NetworkEnvelope getOpenNewDisputeMessage(PB.OpenNewDisputeMessage openNewDisputeMessage) {
return new OpenNewDisputeMessage(ProtoUtil.getDispute(openNewDisputeMessage.getDispute()),
NodeAddress.fromProto(openNewDisputeMessage.getMyNodeAddress()), openNewDisputeMessage.getUid());
NodeAddress.fromProto(openNewDisputeMessage.getSenderNodeAddress()), openNewDisputeMessage.getUid());
}
private static NetworkEnvelope getDisputeCommunicationMessage(PB.DisputeCommunicationMessage disputeCommunicationMessage) {
@ -322,7 +322,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
disputeCommunicationMessage.getAttachmentsList().stream()
.map(attachment -> new Attachment(attachment.getFileName(), attachment.getBytes().toByteArray()))
.collect(Collectors.toList()),
NodeAddress.fromProto(disputeCommunicationMessage.getMyNodeAddress()),
NodeAddress.fromProto(disputeCommunicationMessage.getSenderNodeAddress()),
disputeCommunicationMessage.getDate(),
disputeCommunicationMessage.getArrived(),
disputeCommunicationMessage.getStoredInMailbox(),

View File

@ -26,24 +26,22 @@ import io.bisq.generated.protobuffer.PB;
import io.bisq.network.p2p.MailboxMessage;
import io.bisq.network.p2p.NodeAddress;
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.util.encoders.Hex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.concurrent.Immutable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@EqualsAndHashCode(callSuper = true)
@Immutable
// We use a MailboxMessage here because the taker has paid already the trade fee and it could be that
// we lost connection to him but we are complete on our side. So even if the peer is offline he can
// continue later to complete the deposit tx.
@EqualsAndHashCode(callSuper = true)
@Value
@Slf4j
public final class PublishDepositTxRequest extends TradeMessage implements MailboxMessage {
private static final Logger log = LoggerFactory.getLogger(PublishDepositTxRequest.class);
public final PaymentAccountPayload makerPaymentAccountPayload;
public final String makerAccountId;
public final String makerContractAsJson;
@ -55,6 +53,12 @@ public final class PublishDepositTxRequest extends TradeMessage implements Mailb
private final NodeAddress senderNodeAddress;
private final String uid;
@Override
public NodeAddress getSenderNodeAddress() {
return null;
}
public PublishDepositTxRequest(String tradeId,
PaymentAccountPayload makerPaymentAccountPayload,
String makerAccountId,
@ -115,14 +119,4 @@ public final class PublishDepositTxRequest extends TradeMessage implements Mailb
", makerMultiSigPubKey=" + Hex.toHexString(makerMultiSigPubKey) +
"} " + super.toString();
}
@Override
public NodeAddress getSenderNodeAddress() {
return null;
}
@Override
public String getUid() {
return null;
}
}