Use PopupManager for queuing popups, improve version handling, deactivate focus requests, add popup when getting disconnection because of version conflict

This commit is contained in:
Manfred Karrer 2016-02-04 13:16:40 +01:00
parent ba4a228fed
commit a264fa4e0b
94 changed files with 421 additions and 288 deletions

View file

@ -10,9 +10,9 @@ import java.util.Arrays;
public final class PrefixedSealedAndSignedMessage implements MailboxMessage, SendersNodeAddressMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
private final NodeAddress senderNodeAddress;
public final SealedAndSigned sealedAndSigned;
public final byte[] addressPrefixHash;
@ -29,14 +29,14 @@ public final class PrefixedSealedAndSignedMessage implements MailboxMessage, Sen
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override
public String toString() {
return "SealedAndSignedMessage{" +
"networkId=" + networkId +
"messageVersion=" + messageVersion +
", sealedAndSigned=" + sealedAndSigned +
", receiverAddressMaskHash.hashCode()=" + Arrays.toString(addressPrefixHash).hashCode() +
'}';

View file

@ -3,5 +3,5 @@ package io.bitsquare.p2p;
import java.io.Serializable;
public interface Message extends Serializable {
int networkId();
int getMessageVersion();
}

View file

@ -108,8 +108,6 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
}
private void init(boolean useLocalhost, int networkId, File storageDir) {
Log.traceCall();
connectionNodeAddressListener = (observable, oldValue, newValue) -> {
UserThread.execute(() -> numConnectedPeers.set(networkNode.getNodeAddressesOfConfirmedConnections().size()));
};

View file

@ -24,9 +24,9 @@ import java.security.PublicKey;
public final class DecryptedMsgWithPubKey implements DirectMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
public final Message message;
public final PublicKey signaturePubKey;
@ -36,8 +36,8 @@ public final class DecryptedMsgWithPubKey implements DirectMessage {
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override
@ -63,7 +63,7 @@ public final class DecryptedMsgWithPubKey implements DirectMessage {
@Override
public String toString() {
return "DecryptedMsgWithPubKey{" +
"networkId=" + networkId +
"messageVersion=" + messageVersion +
", message=" + message +
", signaturePubKey.hashCode()=" + signaturePubKey.hashCode() +
'}';

View file

@ -6,7 +6,6 @@ public enum CloseConnectionReason {
RESET(false),
SOCKET_TIMEOUT(false),
TERMINATED(false), // EOFException
INCOMPATIBLE_DATA(false),
UNKNOWN_EXCEPTION(false),
// Planned

View file

@ -177,10 +177,8 @@ public class Connection implements MessageListener {
objectToWrite = message;
}
if (!stopped) {
synchronized (objectOutputStream) {
objectOutputStream.writeObject(objectToWrite);
objectOutputStream.flush();
}
objectOutputStream.writeObject(objectToWrite);
objectOutputStream.flush();
sharedModel.updateLastActivityDate();
}
} catch (IOException e) {
@ -243,7 +241,7 @@ public class Connection implements MessageListener {
this.peerType = peerType;
}
private synchronized void setPeersNodeAddress(NodeAddress peerNodeAddress) {
private void setPeersNodeAddress(NodeAddress peerNodeAddress) {
checkNotNull(peerNodeAddress, "peerAddress must not be null");
peersNodeAddressOptional = Optional.of(peerNodeAddress);
@ -264,7 +262,7 @@ public class Connection implements MessageListener {
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public synchronized Optional<NodeAddress> getPeersNodeAddressOptional() {
public Optional<NodeAddress> getPeersNodeAddressOptional() {
return peersNodeAddressOptional;
}
@ -292,6 +290,10 @@ public class Connection implements MessageListener {
return nodeAddressProperty;
}
public RuleViolation getRuleViolation() {
return sharedModel.getRuleViolation();
}
///////////////////////////////////////////////////////////////////////////////////////////
// ShutDown
@ -436,11 +438,11 @@ public class Connection implements MessageListener {
this.socket = socket;
}
public synchronized void updateLastActivityDate() {
public void updateLastActivityDate() {
lastActivityDate = new Date();
}
public synchronized Date getLastActivityDate() {
public Date getLastActivityDate() {
return lastActivityDate;
}
@ -477,11 +479,9 @@ public class Connection implements MessageListener {
closeConnectionReason = CloseConnectionReason.RESET;
} else if (e instanceof SocketTimeoutException || e instanceof TimeoutException) {
closeConnectionReason = CloseConnectionReason.SOCKET_TIMEOUT;
log.debug("TimeoutException at socket " + socket.toString() + "\n\tconnection={}" + this);
log.warn("SocketTimeoutException at socket " + socket.toString() + "\n\tconnection={}" + this);
} else if (e instanceof EOFException) {
closeConnectionReason = CloseConnectionReason.TERMINATED;
} else if (e instanceof NoClassDefFoundError || e instanceof ClassNotFoundException) {
closeConnectionReason = CloseConnectionReason.INCOMPATIBLE_DATA;
} else {
closeConnectionReason = CloseConnectionReason.UNKNOWN_EXCEPTION;
log.warn("Unknown reason for exception at socket {}\n\tconnection={}\n\tException=",
@ -499,7 +499,7 @@ public class Connection implements MessageListener {
}
}
public synchronized Socket getSocket() {
public Socket getSocket() {
return socket;
}
@ -522,9 +522,9 @@ public class Connection implements MessageListener {
}
///////////////////////////////////////////////////////////////////////////////////////////
// InputHandler
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// InputHandler
///////////////////////////////////////////////////////////////////////////////////////////
// Runs in same thread as Connection
private static class InputHandler implements Runnable {
@ -547,11 +547,15 @@ public class Connection implements MessageListener {
}
public void stop() {
stopped = true;
try {
objectInputStream.close();
} catch (IOException e) {
e.printStackTrace();
if (!stopped) {
try {
objectInputStream.close();
} catch (IOException e) {
log.error("IOException at InputHandler.stop\n" + e.getMessage());
e.printStackTrace();
} finally {
stopped = true;
}
}
}
@ -573,7 +577,7 @@ public class Connection implements MessageListener {
int size = ByteArrayUtils.objectToByteArray(rawInputObject).length;
if (size > getMaxMsgSize()) {
sharedModel.reportInvalidRequest(RuleViolation.MAX_MSG_SIZE_EXCEEDED);
reportInvalidRequest(RuleViolation.MAX_MSG_SIZE_EXCEEDED);
return;
}
@ -585,36 +589,38 @@ public class Connection implements MessageListener {
//log.trace("Read object compressed data size: " + size);
serializable = Utils.decompress(compressedObjectAsBytes);
} else {
sharedModel.reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
return;
}
} else {
if (rawInputObject instanceof Serializable) {
serializable = (Serializable) rawInputObject;
} else {
sharedModel.reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
return;
}
}
//log.trace("Read object decompressed data size: " + ByteArrayUtils.objectToByteArray(serializable).length);
// compressed size might be bigger theoretically so we check again after decompression
if (size > getMaxMsgSize()) {
sharedModel.reportInvalidRequest(RuleViolation.MAX_MSG_SIZE_EXCEEDED);
reportInvalidRequest(RuleViolation.MAX_MSG_SIZE_EXCEEDED);
return;
}
if (sharedModel.connection.violatesThrottleLimit()) {
sharedModel.reportInvalidRequest(RuleViolation.THROTTLE_LIMIT_EXCEEDED);
reportInvalidRequest(RuleViolation.THROTTLE_LIMIT_EXCEEDED);
return;
}
if (!(serializable instanceof Message)) {
sharedModel.reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
return;
}
Message message = (Message) serializable;
if (message.networkId() != Version.getNetworkId()) {
sharedModel.reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID);
if (message.getMessageVersion() != Version.getP2PMessageVersion()) {
reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID);
return;
}
@ -624,7 +630,7 @@ public class Connection implements MessageListener {
CloseConnectionReason[] values = CloseConnectionReason.values();
log.info("CloseConnectionMessage received. Reason={}\n\t" +
"connection={}", ((CloseConnectionMessage) message).reason, connection);
stopped = true;
stop();
sharedModel.shutDown(CloseConnectionReason.CLOSE_REQUESTED_BY_PEER);
} else if (!stopped) {
// First a seed node gets a message form a peer (PreliminaryDataRequest using
@ -655,17 +661,26 @@ public class Connection implements MessageListener {
messageListener.onMessage(message, connection);
}
} catch (IOException | ClassNotFoundException | NoClassDefFoundError e) {
stopped = true;
sharedModel.handleConnectionException(e);
reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
return;
} catch (Throwable t) {
t.printStackTrace();
stop();
sharedModel.handleConnectionException(new Exception(t));
}
}
} catch (Throwable t) {
t.printStackTrace();
stopped = true;
stop();
sharedModel.handleConnectionException(new Exception(t));
}
}
private void reportInvalidRequest(RuleViolation ruleViolation) {
sharedModel.reportInvalidRequest(ruleViolation);
stop();
}
@Override
public String toString() {
return "InputHandler{" +

View file

@ -46,12 +46,10 @@ public class LocalhostNetworkNode extends NetworkNode {
public LocalhostNetworkNode(int port) {
super(port);
Log.traceCall();
}
@Override
public void start(@Nullable SetupListener setupListener) {
Log.traceCall();
if (setupListener != null)
addSetupListener(setupListener);
@ -89,7 +87,6 @@ public class LocalhostNetworkNode extends NetworkNode {
// Called from NetworkNode thread
@Override
protected Socket createSocket(NodeAddress peerNodeAddress) throws IOException {
Log.traceCall();
return new Socket(peerNodeAddress.hostName, peerNodeAddress.port);
}
@ -99,7 +96,6 @@ public class LocalhostNetworkNode extends NetworkNode {
///////////////////////////////////////////////////////////////////////////////////////////
private void createTorNode(final Consumer<TorNode> resultHandler) {
Log.traceCall();
ListenableFuture<TorNode<JavaOnionProxyManager, JavaOnionProxyContext>> future = executorService.submit(() -> {
Utilities.setThreadName("NetworkNode:CreateTorNode");
long ts = System.currentTimeMillis();
@ -129,7 +125,6 @@ public class LocalhostNetworkNode extends NetworkNode {
}
private void createHiddenService(final Consumer<HiddenServiceDescriptor> resultHandler) {
Log.traceCall();
ListenableFuture<HiddenServiceDescriptor> future = executorService.submit(() -> {
Utilities.setThreadName("NetworkNode:CreateHiddenService");
long ts = System.currentTimeMillis();

View file

@ -5,9 +5,11 @@ import io.bitsquare.p2p.Message;
public final class CloseConnectionMessage implements Message {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
// We dont use the Version.NETWORK_PROTOCOL_VERSION here as we report also compatibility issues and
// a changed version would render that message invalid as well, so the peer cannot get notified about the problem.
private static final long serialVersionUID = 0;
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
public final String reason;
public CloseConnectionMessage(String reason) {
@ -15,15 +17,15 @@ public final class CloseConnectionMessage implements Message {
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override
public String toString() {
return "CloseConnectionMessage{" +
"messageVersion=" + messageVersion +
", reason=" + reason +
", networkId=" + networkId +
'}';
}
}

View file

@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit;
public class ReportedPeer implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final NodeAddress nodeAddress;
public Date lastActivityDate;

View file

@ -8,8 +8,8 @@ import java.util.HashSet;
public final class GetDataResponse implements Message {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private final int networkId = Version.getNetworkId();
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final int messageVersion = Version.getP2PMessageVersion();
public final HashSet<ProtectedData> dataSet;
public final long requestNonce;
@ -20,14 +20,14 @@ public final class GetDataResponse implements Message {
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override
public String toString() {
return "GetDataResponse{" +
"networkId=" + networkId +
"messageVersion=" + messageVersion +
", dataSet.size()=" + dataSet.size() +
", requestNonce=" + requestNonce +
'}';

View file

@ -6,9 +6,9 @@ import io.bitsquare.p2p.network.messages.SendersNodeAddressMessage;
public final class GetUpdatedDataRequest implements SendersNodeAddressMessage, GetDataRequest {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
private final NodeAddress senderNodeAddress;
private final long nonce;
@ -28,14 +28,14 @@ public final class GetUpdatedDataRequest implements SendersNodeAddressMessage, G
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override
public String toString() {
return "GetUpdatedDataRequest{" +
"networkId=" + networkId +
"messageVersion=" + messageVersion +
", senderNodeAddress=" + senderNodeAddress +
", nonce=" + nonce +
'}';

View file

@ -5,9 +5,9 @@ import io.bitsquare.p2p.network.messages.AnonymousMessage;
public final class PreliminaryGetDataRequest implements AnonymousMessage, GetDataRequest {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
private final long nonce;
public PreliminaryGetDataRequest(long nonce) {
@ -20,14 +20,14 @@ public final class PreliminaryGetDataRequest implements AnonymousMessage, GetDat
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override
public String toString() {
return "PreliminaryGetDataRequest{" +
"networkId=" + networkId +
"messageVersion=" + messageVersion +
", nonce=" + nonce +
'}';
}

View file

@ -9,7 +9,7 @@ import java.util.HashSet;
public final class GetPeersRequest extends PeerExchangeMessage implements SendersNodeAddressMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final NodeAddress senderNodeAddress;
public long nonce;

View file

@ -7,7 +7,7 @@ import java.util.HashSet;
public final class GetPeersResponse extends PeerExchangeMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final long requestNonce;
public final HashSet<ReportedPeer> reportedPeers;

View file

@ -4,17 +4,17 @@ import io.bitsquare.app.Version;
import io.bitsquare.p2p.Message;
public abstract class PeerExchangeMessage implements Message {
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override
public String toString() {
return "PeerExchangeMessage{" +
"networkId=" + networkId +
"messageVersion=" + messageVersion +
'}';
}
}

View file

@ -33,8 +33,8 @@ public class SeedNode {
private final String defaultUserDataDir;
public SeedNode(String defaultUserDataDir) {
Log.traceCall("defaultUserDataDir=" + defaultUserDataDir);
this.defaultUserDataDir = defaultUserDataDir;
Log.traceCall();
}
@ -48,21 +48,23 @@ public class SeedNode {
// or when using localhost: localhost:8001 2 20 true localhost:8002|localhost:8003
// BitcoinNetworkId: The id for the bitcoin network (Mainnet = 0, TestNet = 1, Regtest = 2)
public void processArgs(String[] args) {
Log.traceCall();
try {
if (args.length > 0) {
String arg0 = args[0];
checkArgument(arg0.contains(":") && arg0.split(":").length == 2 && arg0.split(":")[1].length() > 3, "Wrong program argument: " + arg0);
mySeedNodeAddress = new NodeAddress(arg0);
log.info("From processArgs: mySeedNodeAddress=" + mySeedNodeAddress);
if (args.length > 1) {
String arg1 = args[1];
int networkId = Integer.parseInt(arg1);
log.info("From processArgs: networkId=" + networkId);
checkArgument(networkId > -1 && networkId < 3,
"networkId out of scope (Mainnet = 0, TestNet = 1, Regtest = 2)");
Version.setNetworkId(networkId);
Version.setBtcNetworkId(networkId);
if (args.length > 2) {
String arg2 = args[2];
int maxConnections = Integer.parseInt(arg2);
log.info("From processArgs: maxConnections=" + maxConnections);
checkArgument(maxConnections < 1000, "maxConnections seems to be a bit too high...");
PeerManager.setMaxConnections(maxConnections);
} else {
@ -73,6 +75,7 @@ public class SeedNode {
String arg3 = args[3];
checkArgument(arg3.equals("true") || arg3.equals("false"));
useLocalhost = ("true").equals(arg3);
log.info("From processArgs: useLocalhost=" + useLocalhost);
}
if (args.length > 4) {
String arg4 = args[4];
@ -85,6 +88,7 @@ public class SeedNode {
"Wrong program argument");
progArgSeedNodes.add(new NodeAddress(e));
});
log.info("From processArgs: progArgSeedNodes=" + progArgSeedNodes);
progArgSeedNodes.remove(mySeedNodeAddress);
} else if (args.length > 5) {
log.error("Too many program arguments." +
@ -99,7 +103,7 @@ public class SeedNode {
}
public void createAndStartP2PService(boolean useDetailedLogging) {
createAndStartP2PService(mySeedNodeAddress, useLocalhost, Version.getNetworkId(), useDetailedLogging, progArgSeedNodes, null);
createAndStartP2PService(mySeedNodeAddress, useLocalhost, Version.getBtcNetworkId(), useDetailedLogging, progArgSeedNodes, null);
}
@VisibleForTesting
@ -109,8 +113,6 @@ public class SeedNode {
boolean useDetailedLogging,
@Nullable Set<NodeAddress> progArgSeedNodes,
@Nullable P2PServiceListener listener) {
Log.traceCall();
Path appPath = Paths.get(defaultUserDataDir,
"Bitsquare_seed_node_" + String.valueOf(mySeedNodeAddress.getFullAddress().replace(":", "_")));
@ -141,18 +143,14 @@ public class SeedNode {
@VisibleForTesting
public P2PService getSeedNodeP2PService() {
Log.traceCall();
return seedNodeP2PService;
}
private void shutDown() {
Log.traceCall();
shutDown(null);
}
public void shutDown(@Nullable Runnable shutDownCompleteHandler) {
Log.traceCall();
log.debug("Request shutdown seed node");
if (!stopped) {
stopped = true;

View file

@ -53,7 +53,6 @@ public class P2PDataStorage implements MessageListener {
///////////////////////////////////////////////////////////////////////////////////////////
public P2PDataStorage(Broadcaster broadcaster, NetworkNode networkNode, File storageDir) {
Log.traceCall();
this.broadcaster = broadcaster;
networkNode.addMessageListener(this);
@ -65,7 +64,6 @@ public class P2PDataStorage implements MessageListener {
}
private void init() {
Log.traceCall();
HashMap<ByteArray, Integer> persisted = storage.initAndGetPersisted("SequenceNumberMap");
if (persisted != null)
sequenceNumberMap = persisted;
@ -264,7 +262,6 @@ public class P2PDataStorage implements MessageListener {
}
public void addHashMapChangedListener(HashMapChangedListener hashMapChangedListener) {
Log.traceCall();
hashMapChangedListeners.add(hashMapChangedListener);
}

View file

@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit;
public final class ExpirableMailboxPayload implements ExpirablePayload {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private static final long TTL = TimeUnit.DAYS.toMillis(10);

View file

@ -5,7 +5,7 @@ import io.bitsquare.p2p.storage.data.ProtectedData;
public final class AddDataMessage extends DataBroadcastMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final ProtectedData data;

View file

@ -4,17 +4,17 @@ import io.bitsquare.app.Version;
import io.bitsquare.p2p.Message;
public abstract class DataBroadcastMessage implements Message {
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override
public String toString() {
return "DataBroadcastMessage{" +
"networkId=" + networkId +
"messageVersion=" + messageVersion +
'}';
}
}

View file

@ -5,7 +5,7 @@ import io.bitsquare.p2p.storage.data.ProtectedData;
public final class RemoveDataMessage extends DataBroadcastMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final ProtectedData data;

View file

@ -5,7 +5,7 @@ import io.bitsquare.p2p.storage.data.ProtectedMailboxData;
public final class RemoveMailboxDataMessage extends DataBroadcastMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final ProtectedMailboxData data;

View file

@ -83,7 +83,7 @@ public class EncryptionServiceTests {
final class TestMessage implements MailboxMessage {
public String data = "test";
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
public TestMessage(String data) {
this.data = data;
@ -95,7 +95,7 @@ final class TestMessage implements MailboxMessage {
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
}

View file

@ -6,7 +6,7 @@ import io.bitsquare.p2p.messaging.MailboxMessage;
import io.bitsquare.p2p.storage.data.ExpirablePayload;
public final class MockMailboxMessage implements MailboxMessage, ExpirablePayload {
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
public final String msg;
public final NodeAddress senderNodeAddress;
public long ttl;
@ -17,8 +17,8 @@ public final class MockMailboxMessage implements MailboxMessage, ExpirablePayloa
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override

View file

@ -7,15 +7,15 @@ import io.bitsquare.p2p.storage.data.ExpirablePayload;
public final class MockMessage implements Message, ExpirablePayload {
public final String msg;
public long ttl;
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
public MockMessage(String msg) {
this.msg = msg;
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override