Skip to content

Commit

Permalink
ConfidentialMessage: Add version field
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Dec 12, 2022
1 parent ba4d623 commit 07e9d22
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -34,10 +34,18 @@
@EqualsAndHashCode
@Getter
public final class ConfidentialMessage implements NetworkMessage, DistributedData {
private static final int VERSION = 0;

private final int version;
private final ConfidentialData confidentialData;
private final String receiverKeyId;

public ConfidentialMessage(ConfidentialData confidentialData, String receiverKeyId) {
this(VERSION, confidentialData, receiverKeyId);
}

private ConfidentialMessage(int version, ConfidentialData confidentialData, String receiverKeyId) {
this.version = version;
this.confidentialData = confidentialData;
this.receiverKeyId = receiverKeyId;
}
@@ -46,14 +54,18 @@ public ConfidentialMessage(ConfidentialData confidentialData, String receiverKey
public bisq.network.protobuf.NetworkMessage toProto() {
return getNetworkMessageBuilder().setConfidentialMessage(
bisq.network.protobuf.ConfidentialMessage.newBuilder()
.setVersion(VERSION)
.setConfidentialData(confidentialData.toProto())
.setReceiverKeyId(receiverKeyId)
).build();
}

public static ConfidentialMessage fromProto(bisq.network.protobuf.ConfidentialMessage proto) {
return new ConfidentialMessage(ConfidentialData.fromProto(proto.getConfidentialData()),
proto.getReceiverKeyId());
return new ConfidentialMessage(
proto.getVersion(),
ConfidentialData.fromProto(proto.getConfidentialData()),
proto.getReceiverKeyId()
);
}

@Override
5 changes: 3 additions & 2 deletions network/src/main/proto/network.proto
Original file line number Diff line number Diff line change
@@ -99,8 +99,9 @@ message Pong {
}

message ConfidentialMessage {
security.ConfidentialData confidentialData = 1;
string receiverKeyId = 2;
uint32 version = 1;
security.ConfidentialData confidentialData = 2;
string receiverKeyId = 3;
}

message InventoryRequest {

0 comments on commit 07e9d22

Please sign in to comment.