mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 15:26:03 -04:00
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:
parent
ba4a228fed
commit
a264fa4e0b
@ -28,34 +28,46 @@ public class Version {
|
||||
|
||||
// The version nr. for the objects sent over the network. A change will break the serialization of old objects.
|
||||
// If objects are used for both network and database the network version is applied.
|
||||
public static final long NETWORK_PROTOCOL_VERSION = 2;
|
||||
public static final long P2P_NETWORK_VERSION = 1;
|
||||
|
||||
// The version nr. of the serialized data stored to disc. A change will break the serialization of old objects.
|
||||
public static final long LOCAL_DB_VERSION = 2;
|
||||
public static final long LOCAL_DB_VERSION = 1;
|
||||
|
||||
// The version nr. of the current protocol. The offer holds that version.
|
||||
// A taker will check the version of the offers to see if his version is compatible.
|
||||
// TODO not used yet
|
||||
public static final long PROTOCOL_VERSION = 1;
|
||||
public static final long TRADE_PROTOCOL_VERSION = 1;
|
||||
|
||||
// The version for the bitcoin network (Mainnet = 0, TestNet = 1, Regtest = 2)
|
||||
private static int NETWORK_ID;
|
||||
|
||||
public static int getNetworkId() {
|
||||
return NETWORK_ID;
|
||||
public static int getP2PMessageVersion() {
|
||||
// A changed NETWORK_PROTOCOL_VERSION for the serialized objects does not trigger reliable a disconnect.
|
||||
// TODO investigate why, but java serialisation should be replaced anyway, so using one existing field
|
||||
// for the version is fine.
|
||||
// BTC_NETWORK_ID is 0, 1 or 2, we use for changes at NETWORK_PROTOCOL_VERSION a multiplication with 10
|
||||
// to avoid conflicts:
|
||||
// E.g. btc BTC_NETWORK_ID=1, NETWORK_PROTOCOL_VERSION=1 -> getNetworkId()=2;
|
||||
// BTC_NETWORK_ID=0, NETWORK_PROTOCOL_VERSION=2 -> getNetworkId()=2; -> wrong
|
||||
return BTC_NETWORK_ID + 10 * (int) P2P_NETWORK_VERSION;
|
||||
}
|
||||
|
||||
public static void setNetworkId(int networkId) {
|
||||
NETWORK_ID = networkId;
|
||||
// The version for the bitcoin network (Mainnet = 0, TestNet = 1, Regtest = 2)
|
||||
private static int BTC_NETWORK_ID;
|
||||
|
||||
public static void setBtcNetworkId(int btcNetworkId) {
|
||||
BTC_NETWORK_ID = btcNetworkId;
|
||||
}
|
||||
|
||||
public static int getBtcNetworkId() {
|
||||
return BTC_NETWORK_ID;
|
||||
}
|
||||
|
||||
public static void printVersion() {
|
||||
log.info("Version{" +
|
||||
"VERSION=" + VERSION +
|
||||
", NETWORK_PROTOCOL_VERSION=" + NETWORK_PROTOCOL_VERSION +
|
||||
", P2P_NETWORK_VERSION=" + P2P_NETWORK_VERSION +
|
||||
", LOCAL_DB_VERSION=" + LOCAL_DB_VERSION +
|
||||
", PROTOCOL_VERSION=" + PROTOCOL_VERSION +
|
||||
", NETWORK_ID=" + NETWORK_ID +
|
||||
", TRADE_PROTOCOL_VERSION=" + TRADE_PROTOCOL_VERSION +
|
||||
", BTC_NETWORK_ID=" + BTC_NETWORK_ID +
|
||||
", getP2PNetworkId()=" + getP2PMessageVersion() +
|
||||
'}');
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import java.util.Arrays;
|
||||
|
||||
public class ByteArray 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 byte[] bytes;
|
||||
|
||||
|
@ -37,7 +37,7 @@ import java.security.spec.X509EncodedKeySpec;
|
||||
*/
|
||||
public class PubKeyRing 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;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PubKeyRing.class);
|
||||
|
||||
|
@ -25,7 +25,7 @@ import java.util.Arrays;
|
||||
|
||||
public final class SealedAndSigned 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 byte[] encryptedSecretKey;
|
||||
public final byte[] encryptedPayloadWithHmac;
|
||||
|
@ -133,14 +133,14 @@ public class FileManager<T> {
|
||||
executor.schedule(saveFileTask, delayInMilli, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public synchronized T read(File file) {
|
||||
public synchronized T read(File file) throws IOException, ClassNotFoundException {
|
||||
log.debug("read" + file);
|
||||
try (final FileInputStream fileInputStream = new FileInputStream(file);
|
||||
final ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) {
|
||||
return (T) objectInputStream.readObject();
|
||||
} catch (Throwable t) {
|
||||
log.error("Exception at read: " + t.getMessage());
|
||||
return null;
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,12 +176,12 @@ public class FileManager<T> {
|
||||
}
|
||||
|
||||
public synchronized void removeAndBackupFile(String fileName) throws IOException {
|
||||
File corruptedBackupDir = new File(Paths.get(dir.getAbsolutePath(), "corrupted").toString());
|
||||
File corruptedBackupDir = new File(Paths.get(dir.getAbsolutePath(), "backup_of_corrupted_data").toString());
|
||||
if (!corruptedBackupDir.exists())
|
||||
if (!corruptedBackupDir.mkdir())
|
||||
log.warn("make dir failed");
|
||||
|
||||
File corruptedFile = new File(Paths.get(dir.getAbsolutePath(), "corrupted", fileName).toString());
|
||||
File corruptedFile = new File(Paths.get(dir.getAbsolutePath(), "backup_of_corrupted_data", fileName).toString());
|
||||
renameTempFileToFile(storageFile, corruptedFile);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
package io.bitsquare.storage;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -158,23 +157,20 @@ public class Storage<T extends Serializable> {
|
||||
log.trace("Backup {} completed in {}msec", storageFile, System.currentTimeMillis() - now);
|
||||
|
||||
return persistedObject;
|
||||
} catch (ClassCastException | IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("Version of persisted class has changed. We cannot read the persisted data anymore. We make a backup and remove the inconsistent " +
|
||||
"file.");
|
||||
} catch (Throwable t) {
|
||||
log.error("Version of persisted class has changed. We cannot read the persisted data anymore. " +
|
||||
"We make a backup and remove the inconsistent file.");
|
||||
log.error(t.getMessage());
|
||||
try {
|
||||
// In case the persisted data have been critical (keys) we keep a backup which might be used for recovery
|
||||
// We keep a backup which might be used for recovery
|
||||
fileManager.removeAndBackupFile(fileName);
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
log.error(e1.getMessage());
|
||||
// We swallow Exception if backup fails
|
||||
}
|
||||
databaseCorruptionHandler.onFileCorrupted(storageFile.getName());
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
log.error(throwable.getMessage());
|
||||
Throwables.propagate(throwable);
|
||||
if (databaseCorruptionHandler != null)
|
||||
databaseCorruptionHandler.onFileCorrupted(storageFile.getName());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class Alert implements PubKeyProtectedExpirablePayload {
|
||||
// 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);
|
||||
|
||||
|
@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class Arbitrator implements PubKeyProtectedExpirablePayload {
|
||||
// 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 static final long TTL = TimeUnit.DAYS.toMillis(10);
|
||||
|
||||
|
@ -40,7 +40,7 @@ import java.util.List;
|
||||
|
||||
public class Dispute 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;
|
||||
private static final Logger log = LoggerFactory.getLogger(Dispute.class);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -32,7 +32,7 @@ import java.util.Date;
|
||||
|
||||
public class DisputeResult 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;
|
||||
private static final Logger log = LoggerFactory.getLogger(DisputeResult.class);
|
||||
|
||||
public enum FeePaymentPolicy {
|
||||
|
@ -34,7 +34,7 @@ import java.util.List;
|
||||
|
||||
public final class DisputeDirectMessage extends DisputeMessage {
|
||||
// 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 Logger log = LoggerFactory.getLogger(DisputeDirectMessage.class);
|
||||
|
||||
private final long date;
|
||||
@ -188,7 +188,7 @@ public final class DisputeDirectMessage extends DisputeMessage {
|
||||
|
||||
public static class Attachment 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;
|
||||
private static final Logger log = LoggerFactory.getLogger(Attachment.class);
|
||||
|
||||
private final byte[] bytes;
|
||||
|
@ -21,10 +21,10 @@ import io.bitsquare.app.Version;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
|
||||
public abstract class DisputeMessage implements MailboxMessage {
|
||||
private final int networkId = Version.getNetworkId();
|
||||
private final int messageVersion = Version.getP2PMessageVersion();
|
||||
|
||||
@Override
|
||||
public int networkId() {
|
||||
return networkId;
|
||||
public int getMessageVersion() {
|
||||
return messageVersion;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import io.bitsquare.p2p.NodeAddress;
|
||||
|
||||
public final class DisputeResultMessage extends DisputeMessage {
|
||||
// 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 DisputeResult disputeResult;
|
||||
private final NodeAddress myNodeAddress;
|
||||
|
@ -23,7 +23,7 @@ import io.bitsquare.p2p.NodeAddress;
|
||||
|
||||
public final class OpenNewDisputeMessage extends DisputeMessage {
|
||||
// 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 Dispute dispute;
|
||||
private final NodeAddress myNodeAddress;
|
||||
|
@ -23,7 +23,7 @@ import io.bitsquare.p2p.NodeAddress;
|
||||
|
||||
public final class PeerOpenedDisputeMessage extends DisputeMessage {
|
||||
// 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 Dispute dispute;
|
||||
private final NodeAddress myNodeAddress;
|
||||
|
||||
|
@ -24,7 +24,7 @@ import java.util.Arrays;
|
||||
|
||||
public final class PeerPublishedPayoutTxMessage extends DisputeMessage {
|
||||
// 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 byte[] transaction;
|
||||
public final String tradeId;
|
||||
|
@ -24,7 +24,7 @@ import java.util.Arrays;
|
||||
|
||||
public class RawInput 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 long index;
|
||||
public final byte[] parentTransaction;
|
||||
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||
|
||||
public class AliPayAccountContractData extends PaymentAccountContractData 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;
|
||||
|
||||
private String accountNr;
|
||||
|
||||
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||
|
||||
public class BlockChainAccountContractData extends PaymentAccountContractData 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;
|
||||
|
||||
private String address;
|
||||
// used in crypto note coins. not supported now but hopefully in future, so leave it for now.
|
||||
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||
|
||||
public class OKPayAccountContractData extends PaymentAccountContractData 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;
|
||||
|
||||
private String accountNr;
|
||||
|
||||
|
@ -24,7 +24,7 @@ import java.io.Serializable;
|
||||
|
||||
public abstract class PaymentAccountContractData 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;
|
||||
|
||||
private final String paymentMethodName;
|
||||
private final String id;
|
||||
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||
|
||||
public class PerfectMoneyAccountContractData extends PaymentAccountContractData 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;
|
||||
|
||||
private String accountNr;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class SepaAccountContractData extends PaymentAccountContractData 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;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SepaAccountContractData.class);
|
||||
|
||||
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||
|
||||
public class SwishAccountContractData extends PaymentAccountContractData 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;
|
||||
|
||||
private String mobileNr;
|
||||
private String holderName;
|
||||
|
@ -36,7 +36,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
public class Contract implements Serializable {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@JsonExclude
|
||||
public static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
||||
public static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
public final Offer offer;
|
||||
private final long tradeAmount;
|
||||
|
@ -49,7 +49,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@JsonExclude
|
||||
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
@JsonExclude
|
||||
private static final Logger log = LoggerFactory.getLogger(Offer.class);
|
||||
|
||||
@ -58,7 +58,6 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||
"take that offer.";
|
||||
public static final String TAC_TAKER = "With taking the offer I commit to the trade conditions as defined.";
|
||||
|
||||
|
||||
public enum Direction {BUY, SELL}
|
||||
|
||||
public enum State {
|
||||
@ -71,12 +70,11 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||
}
|
||||
|
||||
|
||||
// key attributes for lookup
|
||||
private final String id;
|
||||
private final Direction direction;
|
||||
private final String currencyCode;
|
||||
private final long date;
|
||||
|
||||
private final long protocolVersion;
|
||||
private final long fiatPrice;
|
||||
private final long amount;
|
||||
private final long minAmount;
|
||||
@ -138,6 +136,8 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||
this.arbitratorNodeAddresses = arbitratorNodeAddresses;
|
||||
this.acceptedCountryCodes = acceptedCountryCodes;
|
||||
|
||||
protocolVersion = Version.TRADE_PROTOCOL_VERSION;
|
||||
|
||||
date = new Date().getTime();
|
||||
setState(State.UNDEFINED);
|
||||
}
|
||||
@ -258,6 +258,9 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
|
||||
return pubKeyRing.getSignaturePubKey();
|
||||
}
|
||||
|
||||
public long getProtocolVersion() {
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -22,7 +22,7 @@ import io.bitsquare.common.crypto.PubKeyRing;
|
||||
|
||||
public final class OfferAvailabilityRequest extends OfferMessage {
|
||||
// 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 PubKeyRing pubKeyRing;
|
||||
|
||||
|
@ -21,7 +21,7 @@ import io.bitsquare.app.Version;
|
||||
|
||||
public final class OfferAvailabilityResponse extends OfferMessage {
|
||||
// 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 boolean isAvailable;
|
||||
|
||||
|
@ -25,9 +25,9 @@ import javax.annotation.concurrent.Immutable;
|
||||
@Immutable
|
||||
public abstract class OfferMessage 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 String offerId;
|
||||
|
||||
protected OfferMessage(String offerId) {
|
||||
@ -35,14 +35,14 @@ public abstract class OfferMessage implements DirectMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int networkId() {
|
||||
return networkId;
|
||||
public int getMessageVersion() {
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OfferMessage{" +
|
||||
"networkId=" + networkId +
|
||||
"messageVersion=" + messageVersion +
|
||||
", offerId='" + offerId + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import java.util.Arrays;
|
||||
@Immutable
|
||||
public final class DepositTxPublishedMessage extends TradeMessage implements MailboxMessage {
|
||||
// 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 byte[] depositTx;
|
||||
private final NodeAddress senderNodeAddress;
|
||||
|
@ -26,7 +26,7 @@ import javax.annotation.concurrent.Immutable;
|
||||
@Immutable
|
||||
public final class FiatTransferStartedMessage extends TradeMessage implements MailboxMessage {
|
||||
// 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 String buyerPayoutAddress;
|
||||
private final NodeAddress senderNodeAddress;
|
||||
|
@ -27,7 +27,7 @@ import java.util.Arrays;
|
||||
@Immutable
|
||||
public final class FinalizePayoutTxRequest extends TradeMessage implements MailboxMessage {
|
||||
// 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 byte[] sellerSignature;
|
||||
public final String sellerPayoutAddress;
|
||||
|
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@Immutable
|
||||
public final class PayDepositRequest extends TradeMessage implements MailboxMessage {
|
||||
// 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 tradeAmount;
|
||||
public final byte[] takerTradeWalletPubKey;
|
||||
|
@ -27,7 +27,7 @@ import java.util.Arrays;
|
||||
@Immutable
|
||||
public final class PayoutTxFinalizedMessage extends TradeMessage implements MailboxMessage {
|
||||
// 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 byte[] payoutTx;
|
||||
private final NodeAddress senderNodeAddress;
|
||||
|
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@Immutable
|
||||
public final class PublishDepositTxRequest extends TradeMessage {
|
||||
// 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 Logger log = LoggerFactory.getLogger(PublishDepositTxRequest.class);
|
||||
|
||||
|
@ -25,9 +25,9 @@ import javax.annotation.concurrent.Immutable;
|
||||
@Immutable
|
||||
public abstract class TradeMessage 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 String tradeId;
|
||||
|
||||
@Override
|
||||
@ -51,7 +51,7 @@ public abstract class TradeMessage implements DirectMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int networkId() {
|
||||
return networkId;
|
||||
public int getMessageVersion() {
|
||||
return messageVersion;
|
||||
}
|
||||
}
|
||||
|
@ -128,18 +128,24 @@ public class BitsquareApp extends Application {
|
||||
injector = Guice.createInjector(bitsquareAppModule);
|
||||
injector.getInstance(InjectorViewFactory.class).setInjector(injector);
|
||||
|
||||
Version.setNetworkId(injector.getInstance(BitsquareEnvironment.class).getBitcoinNetwork().ordinal());
|
||||
|
||||
// load the main view and create the main scene
|
||||
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
|
||||
mainView = (MainView) viewLoader.load(MainView.class);
|
||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||
Version.setBtcNetworkId(injector.getInstance(BitsquareEnvironment.class).getBitcoinNetwork().ordinal());
|
||||
|
||||
Storage.setDatabaseCorruptionHandler((String fileName) -> {
|
||||
corruptedDatabaseFiles.add(fileName);
|
||||
if (mainView != null)
|
||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||
});
|
||||
|
||||
// load the main view and create the main scene
|
||||
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
|
||||
mainView = (MainView) viewLoader.load(MainView.class);
|
||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||
|
||||
/* Storage.setDatabaseCorruptionHandler((String fileName) -> {
|
||||
corruptedDatabaseFiles.add(fileName);
|
||||
if (mainView != null)
|
||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||
});*/
|
||||
|
||||
scene = new Scene(mainView.getRoot(), 1000, 740);
|
||||
scene.getStylesheets().setAll(
|
||||
|
@ -73,7 +73,8 @@ public class AddressTextField extends AnchorPane {
|
||||
}
|
||||
});
|
||||
textField.focusTraversableProperty().set(focusTraversableProperty().get());
|
||||
focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
||||
//TODO app wide focus
|
||||
//focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
||||
|
||||
Label copyIcon = new Label();
|
||||
copyIcon.setLayoutY(3);
|
||||
|
@ -67,7 +67,8 @@ public class TextFieldWithCopyIcon extends AnchorPane {
|
||||
AnchorPane.setRightAnchor(textField, 30.0);
|
||||
AnchorPane.setLeftAnchor(textField, 0.0);
|
||||
textField.focusTraversableProperty().set(focusTraversableProperty().get());
|
||||
focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
||||
//TODO app wide focus
|
||||
//focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
||||
|
||||
getChildren().addAll(textField, copyIcon);
|
||||
}
|
||||
|
@ -85,7 +85,8 @@ public class TxIdTextField extends AnchorPane {
|
||||
AnchorPane.setRightAnchor(textField, 55.0);
|
||||
AnchorPane.setLeftAnchor(textField, 0.0);
|
||||
textField.focusTraversableProperty().set(focusTraversableProperty().get());
|
||||
focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
||||
//TODO app wide focus
|
||||
//focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());
|
||||
|
||||
getChildren().addAll(textField, copyIcon, progressIndicator);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.gui.main;
|
||||
|
||||
import io.bitsquare.BitsquareException;
|
||||
import io.bitsquare.app.BitsquareApp;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.util.Tuple2;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
@ -184,11 +185,18 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
|
||||
if (!persistedFilesCorrupted.isEmpty()) {
|
||||
// show warning that some files has been corrupted
|
||||
new Popup().warning("Those data base file(s) are not compatible with our current code base." +
|
||||
"\n" + persistedFilesCorrupted.toString() +
|
||||
"\n\nWe made a backup of the corrupted file(s) and applied the default values." +
|
||||
"\n\nThe backup is located at: [data directory]/db/corrupted"
|
||||
).show();
|
||||
new Popup().warning("We detected incompatible data base files!\n\n" +
|
||||
"Those database file(s) are not compatible with our current code base:" +
|
||||
"\n" + persistedFilesCorrupted.toString() +
|
||||
"\n\nWe made a backup of the corrupted file(s) and applied the default values to a new " +
|
||||
"database version." +
|
||||
"\n\nThe backup is located at:\n[you local app data directory]/db/backup_of_corrupted_data.\n\n" +
|
||||
"Please check if you have the latest version of Bitsquare installed.\n" +
|
||||
"You can download it at:\nhttps://github.com/bitsquare/bitsquare/releases\n\n" +
|
||||
"Please restart the application.")
|
||||
.closeButtonText("Shut down")
|
||||
.onClose(BitsquareApp.shutDownHandler::run)
|
||||
.show();
|
||||
}
|
||||
|
||||
transitions.fadeOutAndRemove(splashScreen, 1500, actionEvent -> disposeSplashScreen());
|
||||
@ -358,7 +366,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
model.walletServiceErrorMsg.addListener((ov, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
btcInfoLabel.setId("splash-error-state-msg");
|
||||
btcNetworkWarnMsgPopup = new Popup().warning(newValue).show();
|
||||
btcNetworkWarnMsgPopup = new Popup().warning(newValue);
|
||||
btcNetworkWarnMsgPopup.show();
|
||||
} else {
|
||||
btcInfoLabel.setId("footer-pane");
|
||||
if (btcNetworkWarnMsgPopup != null)
|
||||
@ -407,7 +416,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
p2PNetworkLabel.idProperty().bind(model.p2PNetworkLabelId);
|
||||
model.p2PNetworkWarnMsg.addListener((ov, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
p2PNetworkWarnMsgPopup = new Popup().warning(newValue).show();
|
||||
p2PNetworkWarnMsgPopup = new Popup().warning(newValue);
|
||||
p2PNetworkWarnMsgPopup.show();
|
||||
} else if (p2PNetworkWarnMsgPopup != null) {
|
||||
p2PNetworkWarnMsgPopup.hide();
|
||||
}
|
||||
|
@ -41,6 +41,9 @@ import io.bitsquare.locale.CountryUtil;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.P2PServiceListener;
|
||||
import io.bitsquare.p2p.network.CloseConnectionReason;
|
||||
import io.bitsquare.p2p.network.Connection;
|
||||
import io.bitsquare.p2p.network.ConnectionListener;
|
||||
import io.bitsquare.payment.OKPayAccount;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
@ -187,7 +190,7 @@ public class MainViewModel implements ViewModel {
|
||||
"There might be some network connection problems.\n\n" +
|
||||
"Please restart and try again.")
|
||||
.closeButtonText("Shut down")
|
||||
.onClose(() -> BitsquareApp.shutDownHandler.run())
|
||||
.onClose(BitsquareApp.shutDownHandler::run)
|
||||
.show();
|
||||
});
|
||||
}
|
||||
@ -211,6 +214,34 @@ public class MainViewModel implements ViewModel {
|
||||
private BooleanProperty initP2PNetwork() {
|
||||
final BooleanProperty p2pNetworkInitialized = new SimpleBooleanProperty();
|
||||
p2PNetworkInfo.set("Connecting to Tor network...");
|
||||
p2PService.getNetworkNode().addConnectionListener(new ConnectionListener() {
|
||||
@Override
|
||||
public void onConnection(Connection connection) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect(CloseConnectionReason closeConnectionReason, Connection connection) {
|
||||
// We only check at seed nodes as they are running the latest version
|
||||
// Other disconnects might be caused by peers running an older version
|
||||
if (connection.getPeerType() == Connection.PeerType.SEED_NODE &&
|
||||
closeConnectionReason == CloseConnectionReason.RULE_VIOLATION) {
|
||||
new Popup()
|
||||
.warning("You got disconnected from a seed node.\n\n" +
|
||||
"Reason for getting disconnected: " + connection.getRuleViolation().name() + "\n\n" +
|
||||
"It might be that your installed version is not compatible with " +
|
||||
"the network.\n\n" +
|
||||
"Please check if you run the latest software version.\n" +
|
||||
"You can download the latest version of Bitsquare at:\n" +
|
||||
"https://github.com/bitsquare/bitsquare/releases/\n\n" +
|
||||
"")
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
}
|
||||
});
|
||||
p2PService.start(new P2PServiceListener() {
|
||||
@Override
|
||||
public void onTorNodeReady() {
|
||||
@ -348,8 +379,9 @@ public class MainViewModel implements ViewModel {
|
||||
if (walletService.getWallet().isEncrypted() &&
|
||||
(openOfferManager.getOpenOffers().size() > 0
|
||||
|| tradeManager.getTrades().size() > 0
|
||||
|| disputeManager.getDisputesAsObservableList().size() > 0))
|
||||
walletPasswordPopup.show().onAesKey(aesKey -> tradeWalletService.setAesKey(aesKey));
|
||||
|| disputeManager.getDisputesAsObservableList().size() > 0)) {
|
||||
walletPasswordPopup.onAesKey(aesKey -> tradeWalletService.setAesKey(aesKey)).show();
|
||||
}
|
||||
|
||||
if (tradeManager.pendingTradesInitializedProperty().get() && isSplashScreenRemoved.get())
|
||||
applyTradePeriodState();
|
||||
|
@ -24,6 +24,7 @@ import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.util.Tuple2;
|
||||
import io.bitsquare.gui.common.view.ActivatableViewAndModel;
|
||||
import io.bitsquare.gui.common.view.FxmlView;
|
||||
import io.bitsquare.gui.popups.EnterPrivKeyPopup;
|
||||
import io.bitsquare.gui.popups.Popup;
|
||||
import io.bitsquare.gui.util.FormBuilder;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
|
@ -114,13 +114,13 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
|
||||
|
||||
|
||||
private void askForPassword() {
|
||||
walletPasswordPopup.show().onAesKey(aesKey -> {
|
||||
walletPasswordPopup.onAesKey(aesKey -> {
|
||||
Wallet wallet = walletService.getWallet();
|
||||
KeyCrypter keyCrypter = wallet.getKeyCrypter();
|
||||
keyChainSeed = wallet.getKeyChainSeed();
|
||||
DeterministicSeed decryptedSeed = keyChainSeed.decrypt(keyCrypter, "", aesKey);
|
||||
showSeedScreen(decryptedSeed);
|
||||
});
|
||||
}).show();
|
||||
}
|
||||
|
||||
private void showSeedScreen(DeterministicSeed seed) {
|
||||
|
@ -21,9 +21,9 @@ import io.bitsquare.arbitration.Dispute;
|
||||
import io.bitsquare.arbitration.DisputeManager;
|
||||
import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.gui.common.view.FxmlView;
|
||||
import io.bitsquare.gui.main.disputes.DisputeSummaryPopup;
|
||||
import io.bitsquare.gui.main.disputes.trader.TraderDisputeView;
|
||||
import io.bitsquare.gui.popups.ContractPopup;
|
||||
import io.bitsquare.gui.popups.DisputeSummaryPopup;
|
||||
import io.bitsquare.gui.popups.TradeDetailsPopup;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
|
@ -29,8 +29,8 @@ import io.bitsquare.gui.common.view.ActivatableView;
|
||||
import io.bitsquare.gui.common.view.FxmlView;
|
||||
import io.bitsquare.gui.components.HyperlinkWithIcon;
|
||||
import io.bitsquare.gui.components.TableGroupHeadline;
|
||||
import io.bitsquare.gui.main.disputes.DisputeSummaryPopup;
|
||||
import io.bitsquare.gui.popups.ContractPopup;
|
||||
import io.bitsquare.gui.popups.DisputeSummaryPopup;
|
||||
import io.bitsquare.gui.popups.Popup;
|
||||
import io.bitsquare.gui.popups.TradeDetailsPopup;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
|
@ -310,10 +310,11 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||
}
|
||||
|
||||
private void doWithdraw(Coin amount, FutureCallback<Transaction> callback) {
|
||||
if (walletService.getWallet().isEncrypted())
|
||||
walletPasswordPopup.show().onAesKey(aesKey -> sendFunds(amount, aesKey, callback));
|
||||
else
|
||||
if (walletService.getWallet().isEncrypted()) {
|
||||
walletPasswordPopup.onAesKey(aesKey -> sendFunds(amount, aesKey, callback)).show();
|
||||
} else {
|
||||
sendFunds(amount, null, callback);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendFunds(Coin amount, KeyParameter aesKey, FutureCallback<Transaction> callback) {
|
||||
|
@ -253,10 +253,10 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
|
||||
void onPlaceOffer(Offer offer, TransactionResultHandler resultHandler) {
|
||||
if (walletService.getWallet().isEncrypted() && tradeWalletService.getAesKey() == null) {
|
||||
walletPasswordPopup.show().onAesKey(aesKey -> {
|
||||
walletPasswordPopup.onAesKey(aesKey -> {
|
||||
tradeWalletService.setAesKey(aesKey);
|
||||
doPlaceOffer(offer, resultHandler);
|
||||
});
|
||||
}).show();
|
||||
} else {
|
||||
doPlaceOffer(offer, resultHandler);
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
}
|
||||
}
|
||||
|
||||
private void onShowInfo(boolean isPaymentAccountValidForOffer, boolean hasMatchingArbitrator) {
|
||||
private void onShowInfo(boolean isPaymentAccountValidForOffer, boolean hasMatchingArbitrator, boolean hasSameProtocolVersion) {
|
||||
if (!hasMatchingArbitrator) {
|
||||
showWarning("You don't have an arbitrator selected.",
|
||||
"You need to setup at least one arbitrator to be able to trade.\n" +
|
||||
@ -229,6 +229,13 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
showWarning("You don't have a payment account with the payment method required for that offer.",
|
||||
"You need to setup a payment account with that payment method if you want to take that offer.\n" +
|
||||
"Do you want to do this now?", PaymentAccountView.class);
|
||||
} else if (!hasSameProtocolVersion) {
|
||||
new Popup().information("That offer requires a different protocol version as the one used in your " +
|
||||
"version of the software." +
|
||||
"\n\n" + "Please check if you have the latest version installed, otherwise the user " +
|
||||
"who created the offer has used an older version.\n" +
|
||||
"You cannot trade with an incompatible protocol version.")
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,39 +425,42 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
boolean isTradable;
|
||||
boolean isPaymentAccountValidForOffer;
|
||||
boolean hasMatchingArbitrator;
|
||||
boolean hasSameProtocolVersion;
|
||||
|
||||
{
|
||||
button.setGraphic(iconView);
|
||||
button.setMinWidth(70);
|
||||
}
|
||||
|
||||
private void verifyIfTradable(final Offer offer) {
|
||||
TableRow tableRow = getTableRow();
|
||||
if (tableRow != null) {
|
||||
isPaymentAccountValidForOffer = model.isPaymentAccountValidForOffer(offer);
|
||||
hasMatchingArbitrator = model.hasMatchingArbitrator(offer);
|
||||
isTradable = isPaymentAccountValidForOffer && hasMatchingArbitrator;
|
||||
|
||||
tableRow.setOpacity(isTradable ? 1 : 0.4);
|
||||
|
||||
if (isTradable) {
|
||||
// set first row button as default
|
||||
button.setDefaultButton(getIndex() == 0);
|
||||
tableRow.setOnMouseClicked(null);
|
||||
} else {
|
||||
button.setDefaultButton(false);
|
||||
tableRow.setOnMouseClicked(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(final OfferBookListItem newItem, boolean empty) {
|
||||
super.updateItem(newItem, empty);
|
||||
|
||||
if (newItem != null && !empty) {
|
||||
final Offer offer = newItem.getOffer();
|
||||
verifyIfTradable(offer);
|
||||
|
||||
TableRow tableRow = getTableRow();
|
||||
if (tableRow != null) {
|
||||
isPaymentAccountValidForOffer = model.isPaymentAccountValidForOffer(offer);
|
||||
hasMatchingArbitrator = model.hasMatchingArbitrator(offer);
|
||||
hasSameProtocolVersion = model.hasSameProtocolVersion(offer);
|
||||
isTradable = isPaymentAccountValidForOffer && hasMatchingArbitrator &&
|
||||
hasSameProtocolVersion;
|
||||
|
||||
tableRow.setOpacity(isTradable ? 1 : 0.4);
|
||||
|
||||
if (isTradable) {
|
||||
// set first row button as default
|
||||
button.setDefaultButton(getIndex() == 0);
|
||||
tableRow.setOnMouseClicked(null);
|
||||
} else {
|
||||
button.setDefaultButton(false);
|
||||
tableRow.setOnMouseClicked(e ->
|
||||
onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator,
|
||||
hasSameProtocolVersion));
|
||||
}
|
||||
}
|
||||
|
||||
String title;
|
||||
if (isTradable) {
|
||||
if (model.isMyOffer(offer)) {
|
||||
@ -465,7 +475,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
} else {
|
||||
title = "Not matching";
|
||||
iconView.setId(null);
|
||||
button.setOnAction(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator));
|
||||
button.setOnAction(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion));
|
||||
}
|
||||
|
||||
button.setText(title);
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.gui.main.offer.offerbook;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.gui.common.model.ActivatableViewModel;
|
||||
@ -281,7 +282,6 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public boolean hasMatchingArbitrator(Offer offer) {
|
||||
for (NodeAddress offerArbitratorNodeAddress : offer.getArbitratorNodeAddresses()) {
|
||||
for (NodeAddress acceptedArbitratorNodeAddress : user.getAcceptedArbitratorAddresses()) {
|
||||
@ -291,4 +291,8 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasSameProtocolVersion(Offer offer) {
|
||||
return offer.getProtocolVersion() == Version.TRADE_PROTOCOL_VERSION;
|
||||
}
|
||||
}
|
||||
|
@ -167,10 +167,10 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
||||
// have it persisted as well.
|
||||
void onTakeOffer(TradeResultHandler tradeResultHandler) {
|
||||
if (walletService.getWallet().isEncrypted() && tradeWalletService.getAesKey() == null) {
|
||||
walletPasswordPopup.show().onAesKey(aesKey -> {
|
||||
walletPasswordPopup.onAesKey(aesKey -> {
|
||||
tradeWalletService.setAesKey(aesKey);
|
||||
doTakeOffer(tradeResultHandler);
|
||||
});
|
||||
}).show();
|
||||
} else {
|
||||
doTakeOffer(tradeResultHandler);
|
||||
}
|
||||
|
@ -182,11 +182,11 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
||||
.subscribe((observable, oldValue, newValue) -> {
|
||||
if (!oldValue && newValue) {
|
||||
isOfferAvailablePopup = new Popup().information(BSResources.get("takeOffer.fundsBox.isOfferAvailable"))
|
||||
.show()
|
||||
.onClose(() -> {
|
||||
model.resetErrorMessage();
|
||||
close();
|
||||
}).show();
|
||||
});
|
||||
isOfferAvailablePopup.show();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -170,9 +170,9 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
||||
|
||||
void onWithdrawRequest(String toAddress) {
|
||||
checkNotNull(trade, "trade must not be null");
|
||||
if (walletService.getWallet().isEncrypted())
|
||||
walletPasswordPopup.show().onAesKey(aesKey -> doWithdrawRequest(toAddress, aesKey));
|
||||
else
|
||||
if (walletService.getWallet().isEncrypted()) {
|
||||
walletPasswordPopup.onAesKey(aesKey -> doWithdrawRequest(toAddress, aesKey)).show();
|
||||
} else
|
||||
doWithdrawRequest(toAddress, null);
|
||||
}
|
||||
|
||||
|
@ -110,8 +110,9 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
||||
// Focus selectedItem from model
|
||||
int index = table.getItems().indexOf(model.getSelectedItem());
|
||||
UserThread.execute(() -> {
|
||||
table.requestFocus();
|
||||
UserThread.execute(() -> table.getFocusModel().focus(index));
|
||||
//TODO app wide focus
|
||||
//table.requestFocus();
|
||||
//UserThread.execute(() -> table.getFocusModel().focus(index));
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -151,9 +152,10 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
||||
// Select and focus selectedItem from model
|
||||
int index = table.getItems().indexOf(selectedItem);
|
||||
UserThread.execute(() -> {
|
||||
//TODO app wide focus
|
||||
table.getSelectionModel().select(index);
|
||||
table.requestFocus();
|
||||
UserThread.execute(() -> table.getFocusModel().focus(index));
|
||||
//table.requestFocus();
|
||||
//UserThread.execute(() -> table.getFocusModel().focus(index));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -69,11 +69,12 @@ public class CompletedView extends TradeStepDetailsView {
|
||||
// We need to handle both cases: Address not set and address already set (when returning from other view)
|
||||
// We get address validation after focus out, so first make sure we loose focus and then set it again as hint for user to put address in
|
||||
UserThread.execute(() -> {
|
||||
withdrawAddressTextField.requestFocus();
|
||||
UserThread.execute(() -> {
|
||||
//TODO app wide focus
|
||||
// withdrawAddressTextField.requestFocus();
|
||||
/* UserThread.execute(() -> {
|
||||
this.requestFocus();
|
||||
UserThread.execute(() -> withdrawAddressTextField.requestFocus());
|
||||
});
|
||||
});*/
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class ContractPopup extends Popup {
|
||||
width = 850;
|
||||
createGridPane();
|
||||
addContent();
|
||||
createPopup();
|
||||
display();
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -152,7 +152,8 @@ public class ContractPopup extends Popup {
|
||||
addLabelTxIdTextField(gridPane, ++rowIndex, "Payout transaction ID:", dispute.getPayoutTxId());
|
||||
|
||||
Button cancelButton = addButtonAfterGroup(gridPane, ++rowIndex, "Close");
|
||||
cancelButton.requestFocus();
|
||||
//TODO app wide focus
|
||||
//cancelButton.requestFocus();
|
||||
cancelButton.setOnAction(e -> {
|
||||
closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
|
||||
hide();
|
||||
|
@ -46,15 +46,14 @@ public class DisplayAlertMessagePopup extends Popup {
|
||||
public DisplayAlertMessagePopup() {
|
||||
}
|
||||
|
||||
public DisplayAlertMessagePopup show() {
|
||||
public void show() {
|
||||
width = 700;
|
||||
// need to set headLine, otherwise the fields will not be created in addHeadLine
|
||||
headLine = "Important information!";
|
||||
createGridPane();
|
||||
addHeadLine();
|
||||
addContent();
|
||||
createPopup();
|
||||
return this;
|
||||
PopupManager.queueForDisplay(this);
|
||||
}
|
||||
|
||||
public DisplayAlertMessagePopup alertMessage(Alert alert) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.main.disputes;
|
||||
package io.bitsquare.gui.popups;
|
||||
|
||||
import io.bitsquare.arbitration.Dispute;
|
||||
import io.bitsquare.arbitration.DisputeManager;
|
||||
@ -26,7 +26,6 @@ import io.bitsquare.btc.TradeWalletService;
|
||||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.btc.exceptions.TransactionVerificationException;
|
||||
import io.bitsquare.common.util.Tuple2;
|
||||
import io.bitsquare.gui.popups.Popup;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.gui.util.Transitions;
|
||||
@ -89,7 +88,7 @@ public class DisputeSummaryPopup extends Popup {
|
||||
width = 850;
|
||||
createGridPane();
|
||||
addContent();
|
||||
createPopup();
|
||||
PopupManager.queueForDisplay(this);
|
||||
}
|
||||
|
||||
public DisputeSummaryPopup onClose(Runnable closeHandler) {
|
@ -64,7 +64,7 @@ public class EmptyWalletPopup extends Popup {
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
public EmptyWalletPopup show() {
|
||||
public void show() {
|
||||
if (headLine == null)
|
||||
headLine = "Empty wallet";
|
||||
|
||||
@ -72,8 +72,7 @@ public class EmptyWalletPopup extends Popup {
|
||||
createGridPane();
|
||||
addHeadLine();
|
||||
addContent();
|
||||
createPopup();
|
||||
return this;
|
||||
PopupManager.queueForDisplay(this);
|
||||
}
|
||||
|
||||
public EmptyWalletPopup onClose(Runnable closeHandler) {
|
||||
|
@ -15,11 +15,10 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.main.account.arbitratorregistration;
|
||||
package io.bitsquare.gui.popups;
|
||||
|
||||
import io.bitsquare.app.BitsquareApp;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
import io.bitsquare.gui.popups.Popup;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
@ -50,7 +49,7 @@ public class EnterPrivKeyPopup extends Popup {
|
||||
public EnterPrivKeyPopup() {
|
||||
}
|
||||
|
||||
public EnterPrivKeyPopup show() {
|
||||
public void show() {
|
||||
if (gridPane != null) {
|
||||
rowIndex = -1;
|
||||
gridPane.getChildren().clear();
|
||||
@ -63,9 +62,7 @@ public class EnterPrivKeyPopup extends Popup {
|
||||
addHeadLine();
|
||||
addInputFields();
|
||||
addButtons();
|
||||
createPopup();
|
||||
|
||||
return this;
|
||||
PopupManager.queueForDisplay(this);
|
||||
}
|
||||
|
||||
public EnterPrivKeyPopup onClose(Runnable closeHandler) {
|
@ -79,7 +79,7 @@ public class OfferDetailsPopup extends Popup {
|
||||
width = 850;
|
||||
createGridPane();
|
||||
addContent();
|
||||
createPopup();
|
||||
display();
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ public class OfferDetailsPopup extends Popup {
|
||||
width = 850;
|
||||
createGridPane();
|
||||
addContent();
|
||||
createPopup();
|
||||
display();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class OpenEmergencyTicketPopup extends Popup {
|
||||
public OpenEmergencyTicketPopup() {
|
||||
}
|
||||
|
||||
public OpenEmergencyTicketPopup show() {
|
||||
public void show() {
|
||||
if (headLine == null)
|
||||
headLine = "Open support ticket";
|
||||
|
||||
@ -50,8 +50,7 @@ public class OpenEmergencyTicketPopup extends Popup {
|
||||
createGridPane();
|
||||
addHeadLine();
|
||||
addContent();
|
||||
createPopup();
|
||||
return this;
|
||||
PopupManager.queueForDisplay(this);
|
||||
}
|
||||
|
||||
public OpenEmergencyTicketPopup onOpenTicket(ResultHandler openTicketHandler) {
|
||||
|
@ -78,7 +78,7 @@ public class Popup {
|
||||
public Popup() {
|
||||
}
|
||||
|
||||
public Popup show() {
|
||||
public void show() {
|
||||
createGridPane();
|
||||
addHeadLine();
|
||||
|
||||
@ -91,13 +91,16 @@ public class Popup {
|
||||
|
||||
addCloseButton();
|
||||
addDontShowAgainCheckBox();
|
||||
createPopup();
|
||||
return this;
|
||||
PopupManager.queueForDisplay(this);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
MainView.removeBlur();
|
||||
stage.hide();
|
||||
if (stage != null)
|
||||
stage.hide();
|
||||
else
|
||||
log.warn("Stage is null");
|
||||
PopupManager.isHidden(this);
|
||||
}
|
||||
|
||||
public Popup onClose(Runnable closeHandler) {
|
||||
@ -207,7 +210,7 @@ public class Popup {
|
||||
FxTimer.runLater(Duration.ofMillis(Transitions.DEFAULT_DURATION), () -> MainView.blurLight());
|
||||
}
|
||||
|
||||
protected void createPopup() {
|
||||
public void display() {
|
||||
if (owner == null)
|
||||
owner = MainView.getRootContainer();
|
||||
|
||||
@ -333,7 +336,8 @@ public class Popup {
|
||||
if (actionHandlerOptional.isPresent() || actionButtonText != null) {
|
||||
actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText);
|
||||
actionButton.setDefaultButton(true);
|
||||
actionButton.requestFocus();
|
||||
//TODO app wide focus
|
||||
//actionButton.requestFocus();
|
||||
actionButton.setOnAction(event -> {
|
||||
hide();
|
||||
actionHandlerOptional.ifPresent(actionHandler -> actionHandler.run());
|
||||
@ -367,4 +371,12 @@ public class Popup {
|
||||
else
|
||||
truncatedMessage = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Popup{" +
|
||||
"headLine='" + headLine + '\'' +
|
||||
", message='" + message + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
40
gui/src/main/java/io/bitsquare/gui/popups/PopupManager.java
Normal file
40
gui/src/main/java/io/bitsquare/gui/popups/PopupManager.java
Normal file
@ -0,0 +1,40 @@
|
||||
package io.bitsquare.gui.popups;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
class PopupManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(PopupManager.class);
|
||||
private static Queue<Popup> popups = new LinkedBlockingQueue<>(3);
|
||||
private static Popup displayedPopup;
|
||||
|
||||
static void queueForDisplay(Popup popup) {
|
||||
boolean result = popups.offer(popup);
|
||||
if (!result)
|
||||
log.warn("The capacity is full with popups in the queue.\n\t" +
|
||||
"Not added new popup=" + popup);
|
||||
displayNext();
|
||||
}
|
||||
|
||||
static void isHidden(Popup popup) {
|
||||
if (displayedPopup == null || displayedPopup == popup) {
|
||||
displayedPopup = null;
|
||||
displayNext();
|
||||
} else {
|
||||
log.warn("We got a isHidden called with a wrong popup.\n\t" +
|
||||
"popup (argument)=" + popup + "\n\tdisplayedPopup=" + displayedPopup);
|
||||
}
|
||||
}
|
||||
|
||||
private static void displayNext() {
|
||||
if (displayedPopup == null) {
|
||||
if (!popups.isEmpty()) {
|
||||
displayedPopup = popups.poll();
|
||||
displayedPopup.display();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,7 @@ public class SelectDepositTxPopup extends Popup {
|
||||
public SelectDepositTxPopup() {
|
||||
}
|
||||
|
||||
public SelectDepositTxPopup show() {
|
||||
public void show() {
|
||||
if (headLine == null)
|
||||
headLine = "Select deposit transaction for dispute";
|
||||
|
||||
@ -60,8 +60,7 @@ public class SelectDepositTxPopup extends Popup {
|
||||
addHeadLine();
|
||||
addContent();
|
||||
addCloseButton();
|
||||
createPopup();
|
||||
return this;
|
||||
PopupManager.queueForDisplay(this);
|
||||
}
|
||||
|
||||
public SelectDepositTxPopup onSelect(Consumer<Transaction> selectHandler) {
|
||||
|
@ -59,7 +59,7 @@ public class SendAlertMessagePopup extends Popup {
|
||||
public SendAlertMessagePopup() {
|
||||
}
|
||||
|
||||
public SendAlertMessagePopup show() {
|
||||
public void show() {
|
||||
if (headLine == null)
|
||||
headLine = "Send global notification";
|
||||
|
||||
@ -67,8 +67,7 @@ public class SendAlertMessagePopup extends Popup {
|
||||
createGridPane();
|
||||
addHeadLine();
|
||||
addContent();
|
||||
createPopup();
|
||||
return this;
|
||||
PopupManager.queueForDisplay(this);
|
||||
}
|
||||
|
||||
public SendAlertMessagePopup onAddAlertMessage(SendAlertMessageHandler sendAlertMessageHandler) {
|
||||
|
@ -65,7 +65,7 @@ public class TradeDetailsPopup extends Popup {
|
||||
width = 850;
|
||||
createGridPane();
|
||||
addContent();
|
||||
createPopup();
|
||||
display();
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -191,7 +191,8 @@ public class TradeDetailsPopup extends Popup {
|
||||
}
|
||||
|
||||
Button cancelButton = addButtonAfterGroup(gridPane, ++rowIndex, "Close");
|
||||
cancelButton.requestFocus();
|
||||
//TODO app wide focus
|
||||
//cancelButton.requestFocus();
|
||||
cancelButton.setOnAction(e -> {
|
||||
closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
|
||||
hide();
|
||||
|
@ -64,7 +64,7 @@ public class WalletPasswordPopup extends Popup {
|
||||
this.walletService = walletService;
|
||||
}
|
||||
|
||||
public WalletPasswordPopup show() {
|
||||
public void show() {
|
||||
if (gridPane != null) {
|
||||
rowIndex = -1;
|
||||
gridPane.getChildren().clear();
|
||||
@ -77,9 +77,7 @@ public class WalletPasswordPopup extends Popup {
|
||||
addHeadLine();
|
||||
addInputFields();
|
||||
addButtons();
|
||||
createPopup();
|
||||
|
||||
return this;
|
||||
PopupManager.queueForDisplay(this);
|
||||
}
|
||||
|
||||
public WalletPasswordPopup onClose(Runnable closeHandler) {
|
||||
|
@ -10,7 +10,12 @@
|
||||
<appender-ref ref="CONSOLE_APPENDER"/>
|
||||
</root>
|
||||
|
||||
|
||||
<!-- <logger name="io.bitsquare.p2p.peers.PeerGroup" level="TRACE"/>
|
||||
|
||||
<logger name="io.bitsquare.storage.Storage" level="WARN"/>
|
||||
<logger name="io.bitsquare.storage.FileManager" level="WARN"/>
|
||||
|
||||
<logger name="io.bitsquare.p2p.P2PService" level="TRACE"/>
|
||||
<logger name="io.bitsquare.p2p.storage.ProtectedExpirableDataStorage" level="TRACE"/>
|
||||
<logger name="io.bitsquare.p2p.network.LocalhostNetworkNode" level="TRACE"/>
|
||||
|
@ -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() +
|
||||
'}';
|
||||
|
@ -3,5 +3,5 @@ package io.bitsquare.p2p;
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface Message extends Serializable {
|
||||
int networkId();
|
||||
int getMessageVersion();
|
||||
}
|
||||
|
@ -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()));
|
||||
};
|
||||
|
@ -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() +
|
||||
'}';
|
||||
|
@ -6,7 +6,6 @@ public enum CloseConnectionReason {
|
||||
RESET(false),
|
||||
SOCKET_TIMEOUT(false),
|
||||
TERMINATED(false), // EOFException
|
||||
INCOMPATIBLE_DATA(false),
|
||||
UNKNOWN_EXCEPTION(false),
|
||||
|
||||
// Planned
|
||||
|
@ -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{" +
|
||||
|
@ -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();
|
||||
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 +
|
||||
'}';
|
||||
|
@ -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 +
|
||||
'}';
|
||||
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user