mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-15 18:00:24 -04:00
Change network version to avoid connecting to bisq nodes (#275)
Co-authored-by: l0nelyc0w <coinrunner@danwin1210.me>
This commit is contained in:
parent
435051f204
commit
00765d7b32
70 changed files with 142 additions and 135 deletions
|
@ -98,7 +98,7 @@ public final class AckMessage extends NetworkEnvelope implements MailboxMessage,
|
|||
String sourceId,
|
||||
boolean success,
|
||||
@Nullable String errorMessage,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.uid = uid;
|
||||
this.senderNodeAddress = senderNodeAddress;
|
||||
|
@ -132,7 +132,7 @@ public final class AckMessage extends NetworkEnvelope implements MailboxMessage,
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static AckMessage fromProto(protobuf.AckMessage proto, int messageVersion) {
|
||||
public static AckMessage fromProto(protobuf.AckMessage proto, String messageVersion) {
|
||||
AckMessageSourceType sourceType = ProtoUtil.enumFromProto(AckMessageSourceType.class, proto.getSourceType());
|
||||
return new AckMessage(proto.getUid(),
|
||||
NodeAddress.fromProto(proto.getSenderNodeAddress()),
|
||||
|
|
|
@ -57,7 +57,7 @@ public final class BundleOfEnvelopes extends BroadcastMessage implements Extende
|
|||
// PROTO BUFFER
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private BundleOfEnvelopes(List<NetworkEnvelope> envelopes, int messageVersion) {
|
||||
private BundleOfEnvelopes(List<NetworkEnvelope> envelopes, String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.envelopes = envelopes;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public final class BundleOfEnvelopes extends BroadcastMessage implements Extende
|
|||
|
||||
public static BundleOfEnvelopes fromProto(protobuf.BundleOfEnvelopes proto,
|
||||
NetworkProtoResolver resolver,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
List<NetworkEnvelope> envelopes = proto.getEnvelopesList()
|
||||
.stream()
|
||||
.map(envelope -> {
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class CloseConnectionMessage extends NetworkEnvelope {
|
|||
// PROTO BUFFER
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private CloseConnectionMessage(String reason, int messageVersion) {
|
||||
private CloseConnectionMessage(String reason, String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.reason = reason;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public final class CloseConnectionMessage extends NetworkEnvelope {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static CloseConnectionMessage fromProto(protobuf.CloseConnectionMessage proto, int messageVersion) {
|
||||
public static CloseConnectionMessage fromProto(protobuf.CloseConnectionMessage proto, String messageVersion) {
|
||||
return new CloseConnectionMessage(proto.getReason(), messageVersion);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public final class PrefixedSealedAndSignedMessage extends NetworkEnvelope implem
|
|||
SealedAndSigned sealedAndSigned,
|
||||
byte[] addressPrefixHash,
|
||||
String uid,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.senderNodeAddress = checkNotNull(senderNodeAddress, "senderNodeAddress must not be null");
|
||||
this.sealedAndSigned = sealedAndSigned;
|
||||
|
@ -84,7 +84,7 @@ public final class PrefixedSealedAndSignedMessage extends NetworkEnvelope implem
|
|||
}
|
||||
|
||||
public static PrefixedSealedAndSignedMessage fromProto(protobuf.PrefixedSealedAndSignedMessage proto,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
return new PrefixedSealedAndSignedMessage(NodeAddress.fromProto(proto.getNodeAddress()),
|
||||
SealedAndSigned.fromProto(proto.getSealedAndSigned()),
|
||||
proto.getAddressPrefixHash().toByteArray(),
|
||||
|
@ -101,7 +101,7 @@ public final class PrefixedSealedAndSignedMessage extends NetworkEnvelope implem
|
|||
SealedAndSigned.fromProto(proto.getSealedAndSigned()),
|
||||
proto.getAddressPrefixHash().toByteArray(),
|
||||
proto.getUid(),
|
||||
-1);
|
||||
"-1");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -842,7 +842,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
return;
|
||||
|
||||
// Check P2P network ID
|
||||
if (proto.getMessageVersion() != Version.getP2PMessageVersion()
|
||||
if (!proto.getMessageVersion().equals(Version.getP2PMessageVersion())
|
||||
&& reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID)) {
|
||||
log.warn("RuleViolation.WRONG_NETWORK_ID. version of message={}, app version={}, " +
|
||||
"proto.toTruncatedString={}", proto.getMessageVersion(),
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class GetDataRequest extends NetworkEnvelope implements Extended
|
|||
@Nullable
|
||||
protected final String version;
|
||||
|
||||
public GetDataRequest(int messageVersion,
|
||||
public GetDataRequest(String messageVersion,
|
||||
int nonce,
|
||||
Set<byte[]> excludedKeys,
|
||||
@Nullable String version) {
|
||||
|
|
|
@ -77,7 +77,7 @@ public final class GetDataResponse extends NetworkEnvelope implements SupportedC
|
|||
int requestNonce,
|
||||
boolean isGetUpdatedDataResponse,
|
||||
@NotNull Capabilities supportedCapabilities,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion);
|
||||
|
||||
this.dataSet = dataSet;
|
||||
|
@ -116,7 +116,7 @@ public final class GetDataResponse extends NetworkEnvelope implements SupportedC
|
|||
|
||||
public static GetDataResponse fromProto(protobuf.GetDataResponse proto,
|
||||
NetworkProtoResolver resolver,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
log.info("Received a GetDataResponse with {}", Utilities.readableFileSize(proto.getSerializedSize()));
|
||||
Set<ProtectedStorageEntry> dataSet = proto.getDataSetList().stream()
|
||||
.map(entry -> (ProtectedStorageEntry) resolver.fromProto(entry)).collect(Collectors.toSet());
|
||||
|
|
|
@ -62,7 +62,7 @@ public final class GetUpdatedDataRequest extends GetDataRequest implements Sende
|
|||
int nonce,
|
||||
Set<byte[]> excludedKeys,
|
||||
@Nullable String version,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion,
|
||||
nonce,
|
||||
excludedKeys,
|
||||
|
@ -87,7 +87,7 @@ public final class GetUpdatedDataRequest extends GetDataRequest implements Sende
|
|||
return proto;
|
||||
}
|
||||
|
||||
public static GetUpdatedDataRequest fromProto(protobuf.GetUpdatedDataRequest proto, int messageVersion) {
|
||||
public static GetUpdatedDataRequest fromProto(protobuf.GetUpdatedDataRequest proto, String messageVersion) {
|
||||
Set<byte[]> excludedKeys = ProtoUtil.byteSetFromProtoByteStringList(proto.getExcludedKeysList());
|
||||
String requestersVersion = ProtoUtil.stringOrNullFromProto(proto.getVersion());
|
||||
log.info("Received a GetUpdatedDataRequest with {} kB and {} excluded key entries. Requesters version={}",
|
||||
|
|
|
@ -61,7 +61,7 @@ public final class PreliminaryGetDataRequest extends GetDataRequest implements A
|
|||
Set<byte[]> excludedKeys,
|
||||
@Nullable String version,
|
||||
Capabilities supportedCapabilities,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion, nonce, excludedKeys, version);
|
||||
|
||||
this.supportedCapabilities = supportedCapabilities;
|
||||
|
@ -84,7 +84,7 @@ public final class PreliminaryGetDataRequest extends GetDataRequest implements A
|
|||
return proto;
|
||||
}
|
||||
|
||||
public static PreliminaryGetDataRequest fromProto(protobuf.PreliminaryGetDataRequest proto, int messageVersion) {
|
||||
public static PreliminaryGetDataRequest fromProto(protobuf.PreliminaryGetDataRequest proto, String messageVersion) {
|
||||
Set<byte[]> excludedKeys = ProtoUtil.byteSetFromProtoByteStringList(proto.getExcludedKeysList());
|
||||
String requestersVersion = ProtoUtil.stringOrNullFromProto(proto.getVersion());
|
||||
log.info("Received a PreliminaryGetDataRequest with {} kB and {} excluded key entries. Requesters version={}",
|
||||
|
|
|
@ -38,7 +38,7 @@ public final class Ping extends NetworkEnvelope implements KeepAliveMessage {
|
|||
// PROTO BUFFER
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private Ping(int nonce, int lastRoundTripTime, int messageVersion) {
|
||||
private Ping(int nonce, int lastRoundTripTime, String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.nonce = nonce;
|
||||
this.lastRoundTripTime = lastRoundTripTime;
|
||||
|
@ -53,7 +53,7 @@ public final class Ping extends NetworkEnvelope implements KeepAliveMessage {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static Ping fromProto(protobuf.Ping proto, int messageVersion) {
|
||||
public static Ping fromProto(protobuf.Ping proto, String messageVersion) {
|
||||
return new Ping(proto.getNonce(), proto.getLastRoundTripTime(), messageVersion);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class Pong extends NetworkEnvelope implements KeepAliveMessage {
|
|||
// PROTO BUFFER
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private Pong(int requestNonce, int messageVersion) {
|
||||
private Pong(int requestNonce, String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.requestNonce = requestNonce;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public final class Pong extends NetworkEnvelope implements KeepAliveMessage {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static Pong fromProto(protobuf.Pong proto, int messageVersion) {
|
||||
public static Pong fromProto(protobuf.Pong proto, String messageVersion) {
|
||||
return new Pong(proto.getRequestNonce(), messageVersion);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public final class GetPeersRequest extends NetworkEnvelope implements PeerExchan
|
|||
int nonce,
|
||||
Set<Peer> reportedPeers,
|
||||
@Nullable Capabilities supportedCapabilities,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion);
|
||||
checkNotNull(senderNodeAddress, "senderNodeAddress must not be null at GetPeersRequest");
|
||||
this.senderNodeAddress = senderNodeAddress;
|
||||
|
@ -93,7 +93,7 @@ public final class GetPeersRequest extends NetworkEnvelope implements PeerExchan
|
|||
.build();
|
||||
}
|
||||
|
||||
public static GetPeersRequest fromProto(protobuf.GetPeersRequest proto, int messageVersion) {
|
||||
public static GetPeersRequest fromProto(protobuf.GetPeersRequest proto, String messageVersion) {
|
||||
return new GetPeersRequest(NodeAddress.fromProto(proto.getSenderNodeAddress()),
|
||||
proto.getNonce(),
|
||||
new HashSet<>(proto.getReportedPeersList().stream()
|
||||
|
|
|
@ -59,7 +59,7 @@ public final class GetPeersResponse extends NetworkEnvelope implements PeerExcha
|
|||
private GetPeersResponse(int requestNonce,
|
||||
Set<Peer> reportedPeers,
|
||||
@Nullable Capabilities supportedCapabilities,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.requestNonce = requestNonce;
|
||||
this.reportedPeers = reportedPeers;
|
||||
|
@ -83,7 +83,7 @@ public final class GetPeersResponse extends NetworkEnvelope implements PeerExcha
|
|||
.build();
|
||||
}
|
||||
|
||||
public static GetPeersResponse fromProto(protobuf.GetPeersResponse proto, int messageVersion) {
|
||||
public static GetPeersResponse fromProto(protobuf.GetPeersResponse proto, String messageVersion) {
|
||||
HashSet<Peer> reportedPeers = proto.getReportedPeersList()
|
||||
.stream()
|
||||
.map(peer -> {
|
||||
|
|
|
@ -42,7 +42,7 @@ public final class AddDataMessage extends BroadcastMessage {
|
|||
// PROTO BUFFER
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private AddDataMessage(ProtectedStorageEntry protectedStorageEntry, int messageVersion) {
|
||||
private AddDataMessage(ProtectedStorageEntry protectedStorageEntry, String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.protectedStorageEntry = protectedStorageEntry;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public final class AddDataMessage extends BroadcastMessage {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static AddDataMessage fromProto(protobuf.AddDataMessage proto, NetworkProtoResolver resolver, int messageVersion) {
|
||||
public static AddDataMessage fromProto(protobuf.AddDataMessage proto, NetworkProtoResolver resolver, String messageVersion) {
|
||||
return new AddDataMessage((ProtectedStorageEntry) resolver.fromProto(proto.getEntry()), messageVersion);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class AddPersistableNetworkPayloadMessage extends BroadcastMessage
|
|||
// PROTO BUFFER
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private AddPersistableNetworkPayloadMessage(PersistableNetworkPayload persistableNetworkPayload, int messageVersion) {
|
||||
private AddPersistableNetworkPayloadMessage(PersistableNetworkPayload persistableNetworkPayload, String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.persistableNetworkPayload = persistableNetworkPayload;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public final class AddPersistableNetworkPayloadMessage extends BroadcastMessage
|
|||
|
||||
public static AddPersistableNetworkPayloadMessage fromProto(protobuf.AddPersistableNetworkPayloadMessage proto,
|
||||
NetworkProtoResolver resolver,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
return new AddPersistableNetworkPayloadMessage((PersistableNetworkPayload) resolver.fromProto(proto.getPayload()),
|
||||
messageVersion);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import lombok.EqualsAndHashCode;
|
|||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public abstract class BroadcastMessage extends NetworkEnvelope {
|
||||
protected BroadcastMessage(int messageVersion) {
|
||||
protected BroadcastMessage(String messageVersion) {
|
||||
super(messageVersion);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public final class RefreshOfferMessage extends BroadcastMessage {
|
|||
byte[] signature,
|
||||
byte[] hashOfPayload,
|
||||
int sequenceNumber,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.hashOfDataAndSeqNr = hashOfDataAndSeqNr;
|
||||
this.signature = signature;
|
||||
|
@ -67,7 +67,7 @@ public final class RefreshOfferMessage extends BroadcastMessage {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static RefreshOfferMessage fromProto(protobuf.RefreshOfferMessage proto, int messageVersion) {
|
||||
public static RefreshOfferMessage fromProto(protobuf.RefreshOfferMessage proto, String messageVersion) {
|
||||
return new RefreshOfferMessage(proto.getHashOfDataAndSeqNr().toByteArray(),
|
||||
proto.getSignature().toByteArray(),
|
||||
proto.getHashOfPayload().toByteArray(),
|
||||
|
|
|
@ -40,7 +40,7 @@ public final class RemoveDataMessage extends BroadcastMessage {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private RemoveDataMessage(ProtectedStorageEntry protectedStorageEntry,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.protectedStorageEntry = protectedStorageEntry;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public final class RemoveDataMessage extends BroadcastMessage {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static RemoveDataMessage fromProto(protobuf.RemoveDataMessage proto, NetworkProtoResolver resolver, int messageVersion) {
|
||||
public static RemoveDataMessage fromProto(protobuf.RemoveDataMessage proto, NetworkProtoResolver resolver, String messageVersion) {
|
||||
return new RemoveDataMessage(ProtectedStorageEntry.fromProto(proto.getProtectedStorageEntry(), resolver), messageVersion);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public final class RemoveMailboxDataMessage extends BroadcastMessage {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private RemoveMailboxDataMessage(ProtectedMailboxStorageEntry protectedMailboxStorageEntry,
|
||||
int messageVersion) {
|
||||
String messageVersion) {
|
||||
super(messageVersion);
|
||||
this.protectedMailboxStorageEntry = protectedMailboxStorageEntry;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public final class RemoveMailboxDataMessage extends BroadcastMessage {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static RemoveMailboxDataMessage fromProto(protobuf.RemoveMailboxDataMessage proto, NetworkProtoResolver resolver, int messageVersion) {
|
||||
public static RemoveMailboxDataMessage fromProto(protobuf.RemoveMailboxDataMessage proto, NetworkProtoResolver resolver, String messageVersion) {
|
||||
return new RemoveMailboxDataMessage(ProtectedMailboxStorageEntry.fromProto(proto.getProtectedStorageEntry(), resolver), messageVersion);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue