Rename Envelope in PB definition to Msg. Rename p2pMessageVersion to MsVersion

This commit is contained in:
Manfred Karrer 2017-05-11 23:17:31 +02:00
parent 4e824e6cf4
commit 05230e3794
44 changed files with 101 additions and 104 deletions

View File

@ -6,11 +6,11 @@ import io.bisq.common.app.Version;
import io.bisq.generated.protobuffer.PB;
public interface Msg extends Marshaller {
static PB.Envelope.Builder getEnv() {
return PB.Envelope.newBuilder().setP2PMessageVersion(Version.getP2PMessageVersion());
static PB.Msg.Builder getEnv() {
return PB.Msg.newBuilder().setMsgVersion(Version.getP2PMessageVersion());
}
int getMessageVersion();
PB.Envelope toEnvelopeProto();
PB.Msg toEnvelopeProto();
}

View File

@ -23,5 +23,5 @@ import io.bisq.generated.protobuffer.PB;
import java.util.Optional;
public interface NetworkProtoResolver {
Optional<Msg> fromProto(PB.Envelope envelope);
Optional<Msg> fromProto(PB.Msg envelope);
}

View File

@ -8,8 +8,8 @@ package io.bisq.protobuffer;
option java_package = "io.bisq.generated.protobuffer";
option java_outer_classname = "PB";
message Envelope {
int32 p2p_message_version = 1;
message Msg {
int32 msg_version = 1;
oneof message {
Ping ping = 2;
Pong pong = 3;

View File

@ -45,8 +45,8 @@ public class PrivateNotificationMsg implements MailboxMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setPrivateNotificationMessage(baseEnvelope.getPrivateNotificationMessageBuilder()
.setMessageVersion(messageVersion)
.setUid(uid)

View File

@ -132,8 +132,8 @@ public final class DisputeCommunicationMsg extends DisputeMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setDisputeCommunicationMessage(PB.DisputeCommunicationMessage.newBuilder()
.setDate(date)
.setTradeId(tradeId)

View File

@ -46,8 +46,8 @@ public final class DisputeResultMsg extends DisputeMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setDisputeResultMessage(PB.DisputeResultMessage.newBuilder()
.setDisputeResult(disputeResult.toProto())
.setMyNodeAddress(myNodeAddress.toProto())

View File

@ -46,8 +46,8 @@ public final class OpenNewDisputeMsg extends DisputeMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setOpenNewDisputeMessage(PB.OpenNewDisputeMessage.newBuilder()
.setDispute(dispute.toProto()).setMyNodeAddress(myNodeAddress.toProto()).setUid(getUID())).build();
}

View File

@ -46,8 +46,8 @@ public final class PeerOpenedDisputeMsg extends DisputeMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setPeerOpenedDisputeMessage(PB.PeerOpenedDisputeMessage.newBuilder()
.setDispute(dispute.toProto())
.setMyNodeAddress(myNodeAddress.toProto())

View File

@ -46,8 +46,8 @@ public final class PeerPublishedPayoutTxMsg extends DisputeMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setPeerPublishedPayoutTxMessage(PB.PeerPublishedPayoutTxMessage.newBuilder()
.setTransaction(ByteString.copyFrom(transaction))
.setTradeId(tradeId)

View File

@ -22,13 +22,13 @@ public final class GetBsqBlocksRequest implements DirectMsg {
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
final PB.GetBsqBlocksRequest.Builder builder = PB.GetBsqBlocksRequest.newBuilder()
.setFromBlockHeight(fromBlockHeight);
return Msg.getEnv().setGetBsqBlocksRequest(builder).build();
}
public static Msg fromProto(PB.Envelope envelope) {
public static Msg fromProto(PB.Msg envelope) {
PB.GetBsqBlocksRequest msg = envelope.getGetBsqBlocksRequest();
return new GetBsqBlocksRequest(msg.getFromBlockHeight());
}

View File

@ -19,13 +19,13 @@ public final class GetBsqBlocksResponse implements DirectMsg, ExtendedDataSizePe
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
final PB.GetBsqBlocksResponse.Builder builder = PB.GetBsqBlocksResponse.newBuilder()
.setBsqBlocksBytes(ByteString.copyFrom(bsqBlocksBytes));
return Msg.getEnv().setGetBsqBlocksResponse(builder).build();
}
public static Msg fromProto(PB.Envelope envelope) {
public static Msg fromProto(PB.Msg envelope) {
PB.GetBsqBlocksResponse msg = envelope.getGetBsqBlocksResponse();
return new GetBsqBlocksResponse(msg.getBsqBlocksBytes().toByteArray());
}

View File

@ -19,7 +19,7 @@ public final class NewBsqBlockBroadcastMsg extends BroadcastMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
final PB.NewBsqBlockBroadcastMsg.Builder builder = PB.NewBsqBlockBroadcastMsg.newBuilder()
.setBsqBlockBytes(ByteString.copyFrom(bsqBlockBytes));
return Msg.getEnv().setNewBsqBlockBroadcastMsg(builder).build();
@ -30,7 +30,7 @@ public final class NewBsqBlockBroadcastMsg extends BroadcastMsg {
return toEnvelopeProto().getNewBsqBlockBroadcastMsg();
}
public static Msg fromProto(PB.Envelope envelope) {
public static Msg fromProto(PB.Msg envelope) {
PB.NewBsqBlockBroadcastMsg msg = envelope.getNewBsqBlockBroadcastMsg();
return new NewBsqBlockBroadcastMsg(msg.getBsqBlockBytes().toByteArray());
}

View File

@ -62,7 +62,7 @@ public final class OfferAvailabilityRequest extends OfferMsg implements Supporte
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
return Msg.getEnv()
.setOfferAvailabilityRequest(PB.OfferAvailabilityRequest.newBuilder()
.setOfferId(offerId)

View File

@ -58,8 +58,8 @@ public final class OfferAvailabilityResponse extends OfferMsg implements Support
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setOfferAvailabilityResponse(PB.OfferAvailabilityResponse.newBuilder().setMessageVersion(getMessageVersion())
.setOfferId(offerId)
.setAvailabilityResult(PB.AvailabilityResult.valueOf(availabilityResult.name()))

View File

@ -2,7 +2,6 @@ package io.bisq.core.proto;
import io.bisq.common.crypto.PubKeyRing;
import io.bisq.common.crypto.SealedAndSigned;
import io.bisq.common.locale.CountryUtil;
import io.bisq.common.network.Msg;
import io.bisq.common.proto.NetworkProtoResolver;
import io.bisq.core.alert.Alert;
@ -19,12 +18,11 @@ import io.bisq.core.dao.blockchain.p2p.GetBsqBlocksResponse;
import io.bisq.core.dao.blockchain.p2p.NewBsqBlockBroadcastMsg;
import io.bisq.core.dao.compensation.CompensationRequestPayload;
import io.bisq.core.filter.Filter;
import io.bisq.core.filter.PaymentAccountFilter;
import io.bisq.core.offer.AvailabilityResult;
import io.bisq.core.offer.OfferPayload;
import io.bisq.core.offer.messages.OfferAvailabilityRequest;
import io.bisq.core.offer.messages.OfferAvailabilityResponse;
import io.bisq.core.payment.payload.*;
import io.bisq.core.payment.payload.PaymentAccountPayload;
import io.bisq.core.trade.messages.*;
import io.bisq.core.trade.statistics.TradeStatistics;
import io.bisq.generated.protobuffer.PB;
@ -48,7 +46,6 @@ import io.bisq.network.p2p.storage.payload.ProtectedMailboxStorageEntry;
import io.bisq.network.p2p.storage.payload.ProtectedStorageEntry;
import io.bisq.network.p2p.storage.payload.StoragePayload;
import lombok.extern.slf4j.Slf4j;
import org.bitcoinj.core.Coin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.util.CollectionUtils;
@ -57,7 +54,7 @@ import javax.inject.Inject;
import java.util.*;
import java.util.stream.Collectors;
import static io.bisq.generated.protobuffer.PB.Envelope.MessageCase.*;
import static io.bisq.generated.protobuffer.PB.Msg.MessageCase.*;
/**
* If the Messages class is giving errors in IntelliJ, you should change the IntelliJ IDEA Platform Properties file,
@ -79,11 +76,11 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
}
///////////////////////////////////////////////////////////////////////////////////////////
// Handle by Envelope.MessagesCase
// Handle by Msg.MessagesCase
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public Optional<Msg> fromProto(PB.Envelope envelope) {
public Optional<Msg> fromProto(PB.Msg envelope) {
if (Objects.isNull(envelope)) {
log.warn("fromProtoBuf called with empty envelope.");
return Optional.empty();
@ -198,7 +195,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
// Msg
///////////////////////////////////////////////////////////////////////////////////////////
private static Msg getOfferAvailabilityRequest(PB.Envelope envelope) {
private static Msg getOfferAvailabilityRequest(PB.Msg envelope) {
PB.OfferAvailabilityRequest msg = envelope.getOfferAvailabilityRequest();
return new OfferAvailabilityRequest(msg.getOfferId(), PubKeyRing.fromProto(msg.getPubKeyRing()), msg.getTakersTradePrice());
}
@ -216,7 +213,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
payoutTxPublishedMessage.getUid());
}
private static Msg getOfferAvailabilityResponse(PB.Envelope envelope) {
private static Msg getOfferAvailabilityResponse(PB.Msg envelope) {
PB.OfferAvailabilityResponse msg = envelope.getOfferAvailabilityResponse();
return new OfferAvailabilityResponse(msg.getOfferId(),
AvailabilityResult.valueOf(
@ -225,7 +222,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
@NotNull
private static Msg getPrefixedSealedAndSignedMessage(PB.Envelope envelope) {
private static Msg getPrefixedSealedAndSignedMessage(PB.Msg envelope) {
return getPrefixedSealedAndSignedMessage(envelope.getPrefixedSealedAndSignedMessage());
}
@ -355,11 +352,11 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
return new RemoveMailboxDataMsg(getProtectedMailBoxStorageEntry(msg.getProtectedStorageEntry()));
}
public static Msg getAddDataMessage(PB.Envelope envelope) {
public static Msg getAddDataMessage(PB.Msg envelope) {
return new AddDataMsg(getProtectedOrMailboxStorageEntry(envelope.getAddDataMessage().getEntry()));
}
private static Msg getRemoveDataMessage(PB.Envelope envelope) {
private static Msg getRemoveDataMessage(PB.Msg envelope) {
return new RemoveDataMsg(getProtectedStorageEntry(envelope.getRemoveDataMessage().getProtectedStorageEntry()));
}
@ -374,7 +371,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
}
@NotNull
private static Msg getGetDataResponse(PB.Envelope envelope) {
private static Msg getGetDataResponse(PB.Msg envelope) {
HashSet<ProtectedStorageEntry> set = new HashSet<>(
envelope.getGetDataResponse().getDataSetList()
.stream()
@ -385,7 +382,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
}
@NotNull
private static Msg getGetPeersResponse(PB.Envelope envelope) {
private static Msg getGetPeersResponse(PB.Msg envelope) {
Msg result;
PB.GetPeersResponse msg = envelope.getGetPeersResponse();
HashSet<Peer> set = new HashSet<>(
@ -399,7 +396,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
}
@NotNull
private static Msg getGetPeersRequest(PB.Envelope envelope) {
private static Msg getGetPeersRequest(PB.Msg envelope) {
NodeAddress nodeAddress;
Msg result;
PB.GetPeersRequest msg = envelope.getGetPeersRequest();
@ -415,7 +412,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
}
@NotNull
private static Msg getGetUpdatedDataRequest(PB.Envelope envelope) {
private static Msg getGetUpdatedDataRequest(PB.Msg envelope) {
NodeAddress nodeAddress;
Msg result;
PB.GetUpdatedDataRequest msg = envelope.getGetUpdatedDataRequest();
@ -426,7 +423,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
}
@NotNull
private static Msg getPreliminaryGetDataRequest(PB.Envelope envelope) {
private static Msg getPreliminaryGetDataRequest(PB.Msg envelope) {
Msg result;
result = new PreliminaryGetDataRequest(envelope.getPreliminaryGetDataRequest().getNonce(),
ProtoUtil.getByteSet(envelope.getPreliminaryGetDataRequest().getExcludedKeysList()));
@ -434,14 +431,14 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
}
@NotNull
private static Msg getCloseConnectionMessage(PB.Envelope envelope) {
private static Msg getCloseConnectionMessage(PB.Msg envelope) {
Msg result;
result = new CloseConnectionMsg(envelope.getCloseConnectionMessage().getReason());
return result;
}
@NotNull
private static Msg getRefreshTTLMessage(PB.Envelope envelope) {
private static Msg getRefreshTTLMessage(PB.Msg envelope) {
Msg result;
PB.RefreshTTLMessage msg = envelope.getRefreshTtlMessage();
result = new RefreshTTLMsg(msg.getHashOfDataAndSeqNr().toByteArray(),
@ -450,14 +447,14 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
}
@NotNull
private static Msg getPong(PB.Envelope envelope) {
private static Msg getPong(PB.Msg envelope) {
Msg result;
result = new Pong(envelope.getPong().getRequestNonce());
return result;
}
@NotNull
private static Msg getPing(PB.Envelope envelope) {
private static Msg getPing(PB.Msg envelope) {
Msg result;
result = new Ping(envelope.getPing().getNonce(), envelope.getPing().getLastRoundTripTime());
return result;

View File

@ -56,8 +56,8 @@ public final class DepositTxPublishedMsg extends TradeMsg implements MailboxMsg
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setDepositTxPublishedMessage(PB.DepositTxPublishedMessage.newBuilder()
.setMessageVersion(getMessageVersion())
.setTradeId(tradeId)

View File

@ -60,8 +60,8 @@ public final class FiatTransferStartedMsg extends TradeMsg implements MailboxMsg
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setFiatTransferStartedMessage(baseEnvelope.getFiatTransferStartedMessageBuilder()
.setMessageVersion(getMessageVersion())
.setTradeId(tradeId)

View File

@ -61,8 +61,8 @@ public final class FinalizePayoutTxRequest extends TradeMsg implements MailboxMs
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setFinalizePayoutTxRequest(PB.FinalizePayoutTxRequest.newBuilder()
.setMessageVersion(getMessageVersion())
.setTradeId(tradeId)

View File

@ -105,8 +105,8 @@ public final class PayDepositRequest extends TradeMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
PB.PayDepositRequest.Builder builderForValue = PB.PayDepositRequest.newBuilder()
.setTradeId(tradeId)
.setTradeAmount(tradeAmount)

View File

@ -55,8 +55,8 @@ public final class PayoutTxPublishedMsg extends TradeMsg implements MailboxMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setPayoutTxPublishedMessage(baseEnvelope.getPayoutTxPublishedMessageBuilder()
.setUid(uid)
.setMessageVersion(getMessageVersion())

View File

@ -88,8 +88,8 @@ public final class PublishDepositTxRequest extends TradeMsg implements MailboxMs
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setPublishDepositTxRequest(baseEnvelope.getPublishDepositTxRequestBuilder()
.setMessageVersion(getMessageVersion())
.setTradeId(tradeId)

View File

@ -17,8 +17,8 @@ public class MarshallerTest {
public void getBaseEnvelopeTest() {
PB.Ping Ping = PB.Ping.newBuilder().setNonce(100).build();
PB.Pong Pong = PB.Pong.newBuilder().setRequestNonce(1000).build();
PB.Envelope envelope1 = PB.Envelope.newBuilder().setPing(Ping).build();
PB.Envelope envelope2 = PB.Envelope.newBuilder().setPong(Pong).build();
PB.Msg envelope1 = PB.Msg.newBuilder().setPing(Ping).build();
PB.Msg envelope2 = PB.Msg.newBuilder().setPong(Pong).build();
log.info(Ping.toString());
log.info(Pong.toString());
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@ -26,12 +26,12 @@ public class MarshallerTest {
envelope1.writeDelimitedTo(outputStream);
envelope2.writeDelimitedTo(outputStream);
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
PB.Envelope envelope3 = PB.Envelope.parseDelimitedFrom(inputStream);
PB.Envelope envelope4 = PB.Envelope.parseDelimitedFrom(inputStream);
PB.Msg envelope3 = PB.Msg.parseDelimitedFrom(inputStream);
PB.Msg envelope4 = PB.Msg.parseDelimitedFrom(inputStream);
log.info("message: {}", envelope3.getPing());
//log.info("peerseesd empty: '{}'",envelope3.getPong().equals(PB.Envelope.) == "");
//log.info("peerseesd empty: '{}'",envelope3.getPong().equals(PB.Msg.) == "");
assertTrue(isPing(envelope3));
assertTrue(!isPing(envelope4));
@ -45,7 +45,7 @@ public class MarshallerTest {
}
public boolean isPing(PB.Envelope envelope) {
public boolean isPing(PB.Msg envelope) {
return !envelope.getPing().getDefaultInstanceForType().equals(envelope.getPing());
}
}

View File

@ -65,7 +65,7 @@ public class EncryptionService {
try {
final byte[] bytes = Encryption.decryptPayloadWithHmac(sealedAndSigned.encryptedPayloadWithHmac, secretKey);
final PB.Envelope envelope = PB.Envelope.parseFrom(bytes);
final PB.Msg envelope = PB.Msg.parseFrom(bytes);
Msg decryptedPayload = networkProtoResolver.fromProto(envelope).get();
return new DecryptedDataTuple(decryptedPayload, sealedAndSigned.sigPublicKey);
} catch (InvalidProtocolBufferException e) {

View File

@ -31,8 +31,8 @@ public final class CloseConnectionMsg implements Msg {
}
//@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder envelopeBuilder = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder envelopeBuilder = Msg.getEnv();
return envelopeBuilder.setCloseConnectionMessage(envelopeBuilder.getCloseConnectionMessageBuilder()
.setMessageVersion(messageVersion)
.setReason(reason)).build();

View File

@ -46,7 +46,7 @@ public final class PrefixedSealedAndSignedMsg implements MailboxMsg, SendersNode
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
return Msg.getEnv().setPrefixedSealedAndSignedMessage(
PB.PrefixedSealedAndSignedMessage.newBuilder()
.setMessageVersion(messageVersion).setNodeAddress(senderNodeAddress.toProto())

View File

@ -193,7 +193,7 @@ public class Connection implements MessageListener {
Thread.sleep(50);
}
PB.Envelope envelope;
PB.Msg envelope;
lastSendTimeStamp = now;
String peersNodeAddress = peersNodeAddressOptional.isPresent() ? peersNodeAddressOptional.get().toString() : "null";
@ -762,11 +762,11 @@ public class Connection implements MessageListener {
}
// Reading the protobuffer message from the inputstream
PB.Envelope envelope;
PB.Msg envelope;
try {
//TODO check
// if (protoInputStream.available() > 0) {
envelope = PB.Envelope.parseDelimitedFrom(protoInputStream);
envelope = PB.Msg.parseDelimitedFrom(protoInputStream);
/* } else {
// we probably got a network issue so return here
// stop();
@ -846,7 +846,7 @@ public class Connection implements MessageListener {
return;
// Check P2P network ID
int messageVersion = envelope.getP2PMessageVersion();
int messageVersion = envelope.getMsgVersion();
if (messageVersion != Version.getP2PMessageVersion()) {
reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID);
if (DevEnv.DEV_MODE)

View File

@ -44,7 +44,7 @@ public final class GetDataResponse implements SupportedCapabilitiesMsg, Extended
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
PB.GetDataResponse.Builder builder = PB.GetDataResponse.newBuilder();
builder.addAllDataSet(
dataSet.stream()

View File

@ -49,7 +49,7 @@ public final class GetUpdatedDataRequest implements SendersNodeAddressMsg, GetDa
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
return Msg.getEnv().setGetUpdatedDataRequest(
PB.GetUpdatedDataRequest.newBuilder()
.setMessageVersion(messageVersion)

View File

@ -60,8 +60,8 @@ public final class PreliminaryGetDataRequest implements AnonymousMsg, GetDataReq
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder envelopeBuilder = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder envelopeBuilder = Msg.getEnv();
PB.PreliminaryGetDataRequest.Builder msgBuilder = envelopeBuilder.getPreliminaryGetDataRequestBuilder()
.setMessageVersion(messageVersion)
.setNonce(nonce);

View File

@ -17,8 +17,8 @@ public final class Ping extends KeepAliveMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setPing(baseEnvelope.getPingBuilder()
.setNonce(nonce)
.setLastRoundTripTime(lastRoundTripTime)).build();

View File

@ -22,8 +22,8 @@ public final class Pong extends KeepAliveMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setPong(PB.Pong.newBuilder().setRequestNonce(requestNonce)).build();
}
}

View File

@ -55,8 +55,8 @@ public final class GetPeersRequest extends PeerExchangeMsg implements SendersNod
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder envelopeBuilder = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder envelopeBuilder = Msg.getEnv();
PB.GetPeersRequest.Builder msgBuilder = envelopeBuilder.getGetPeersRequestBuilder();
msgBuilder
.setNonce(nonce)

View File

@ -44,8 +44,8 @@ public final class GetPeersResponse extends PeerExchangeMsg implements Supported
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder envelopeBuilder = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder envelopeBuilder = Msg.getEnv();
PB.GetPeersResponse.Builder msgBuilder = PB.GetPeersResponse.newBuilder();
msgBuilder.setRequestNonce(requestNonce);

View File

@ -40,8 +40,8 @@ public final class AddDataMsg extends BroadcastMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
PB.AddDataMessage.Builder builder;
PB.ProtectedStorageEntryOrProtectedMailboxStorageEntry.Builder choiceBuilder;
choiceBuilder = PB.ProtectedStorageEntryOrProtectedMailboxStorageEntry.newBuilder();

View File

@ -40,8 +40,8 @@ public final class RefreshTTLMsg extends BroadcastMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder builder = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder builder = Msg.getEnv();
return builder.setRefreshTtlMessage(builder.getRefreshTtlMessageBuilder()
.setHashOfDataAndSeqNr(ByteString.copyFrom(hashOfDataAndSeqNr))
.setHashOfPayload(ByteString.copyFrom(hashOfPayload))

View File

@ -39,8 +39,8 @@ public final class RemoveDataMsg extends BroadcastMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setRemoveDataMessage(PB.RemoveDataMessage.newBuilder()
.setProtectedStorageEntry((PB.ProtectedStorageEntry) protectedStorageEntry.toProto())).build();

View File

@ -39,8 +39,8 @@ public final class RemoveMailboxDataMsg extends BroadcastMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
public PB.Msg toEnvelopeProto() {
PB.Msg.Builder baseEnvelope = Msg.getEnv();
return baseEnvelope.setRemoveMailboxDataMessage(PB.RemoveMailboxDataMessage.newBuilder()
.setProtectedStorageEntry(protectedMailboxStorageEntry.toProto())).build();

View File

@ -23,7 +23,7 @@ import java.util.Optional;
import java.util.concurrent.TimeUnit;
/**
* Envelope message which support a time to live and sender and receiver's pub keys for storage operations.
* Payload which supports a time to live and sender and receiver's pub keys for storage operations.
* It differs from the ProtectedExpirableMessage in the way that the sender is permitted to do an add operation
* but only the receiver is permitted to remove the data.
* That is the typical requirement for a mailbox like system.

View File

@ -135,8 +135,8 @@ public class EncryptionServiceTests {
}
@Override
public PB.Envelope toEnvelopeProto() {
return PB.Envelope.newBuilder().setPing(PB.Ping.newBuilder().setNonce(nonce)).build();
public PB.Msg toEnvelopeProto() {
return PB.Msg.newBuilder().setPing(PB.Ping.newBuilder().setNonce(nonce)).build();
}
}
}
@ -167,7 +167,7 @@ final class TestMsg implements MailboxMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
throw new NotImplementedException();
}
}

View File

@ -176,7 +176,7 @@ public class TestUtils {
public static NetworkProtoResolver getNetworkProtoResolver() {
return new NetworkProtoResolver() {
@Override
public Optional<Msg> fromProto(PB.Envelope envelope) {
public Optional<Msg> fromProto(PB.Msg envelope) {
return Optional.empty();
}
};

View File

@ -28,7 +28,7 @@ public final class MockMailboxPayload implements MailboxMsg, ExpirablePayload {
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
throw new NotImplementedException();
}

View File

@ -21,7 +21,7 @@ public final class MockPayload implements Msg, ExpirablePayload {
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
throw new NotImplementedException();
}

View File

@ -823,7 +823,7 @@ final class StressTestDirectMsg implements DirectMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
throw new NotImplementedException();
}
@ -851,7 +851,7 @@ final class StressTestMailboxMsg implements MailboxMsg {
}
@Override
public PB.Envelope toEnvelopeProto() {
public PB.Msg toEnvelopeProto() {
throw new NotImplementedException();
}

View File

@ -47,7 +47,7 @@ public class AddDataMsgTest {
ProtectedStorageEntry protectedStorageEntry = new ProtectedMailboxStorageEntry(mailboxStoragePayload,
keyRing1.getSignatureKeyPair().getPublic(), 1, RandomUtils.nextBytes(10), keyRing1.getPubKeyRing().getSignaturePubKey());
AddDataMsg dataMessage1 = new AddDataMsg(protectedStorageEntry);
PB.Envelope envelope = dataMessage1.toEnvelopeProto();
PB.Msg envelope = dataMessage1.toEnvelopeProto();
//TODO CoreProtobufferResolver is not accessible here
// We should refactor it so that the classes themselves know how to deserialize