Add error handling for serialization inconsistency

This commit is contained in:
Manfred Karrer 2015-04-17 15:23:35 +02:00
parent 0344235a23
commit 63c9b4670f
56 changed files with 210 additions and 71 deletions

View file

@ -27,8 +27,8 @@ public class Version {
public static final int MINOR_VERSION = 2; public static final int MINOR_VERSION = 2;
public static final int PATCH_VERSION = 1; public static final int PATCH_VERSION = 1;
public static final byte[] NETWORK_PROTOCOL_VERSION = new byte[]{0x01}; public static final long NETWORK_PROTOCOL_VERSION = 1;
public static final int LOCLA_DB_VERSION = 1; public static final long LOCAL_DB_VERSION = 1;
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + PATCH_VERSION; public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + PATCH_VERSION;

View file

@ -17,6 +17,7 @@
package io.bitsquare.arbitration; package io.bitsquare.arbitration;
import io.bitsquare.app.Version;
import io.bitsquare.crypto.Util; import io.bitsquare.crypto.Util;
import io.bitsquare.locale.LanguageUtil; import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
@ -47,7 +48,7 @@ import org.slf4j.LoggerFactory;
public class ArbitrationRepository implements Serializable { public class ArbitrationRepository implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(ArbitrationRepository.class); transient private static final Logger log = LoggerFactory.getLogger(ArbitrationRepository.class);
transient private final ArbitratorService arbitratorService; transient private final ArbitratorService arbitratorService;
@ -63,7 +64,6 @@ public class ArbitrationRepository implements Serializable {
public ArbitrationRepository(Storage<ArbitrationRepository> storage, public ArbitrationRepository(Storage<ArbitrationRepository> storage,
Storage<Arbitrator> arbitratorStorage, Storage<Arbitrator> arbitratorStorage,
ArbitratorService arbitratorService) throws InvalidKeySpecException, NoSuchAlgorithmException { ArbitratorService arbitratorService) throws InvalidKeySpecException, NoSuchAlgorithmException {
Storage<ArbitrationRepository> storage1 = storage;
this.arbitratorService = arbitratorService; this.arbitratorService = arbitratorService;
byte[] walletPubKey = Utils.HEX.decode("03a418bf0cb60a35ce217c7f80a2db08a4f5efbe56a0e7602fbc392dea6b63f840"); byte[] walletPubKey = Utils.HEX.decode("03a418bf0cb60a35ce217c7f80a2db08a4f5efbe56a0e7602fbc392dea6b63f840");

View file

@ -17,6 +17,7 @@
package io.bitsquare.arbitration; package io.bitsquare.arbitration;
import io.bitsquare.app.Version;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
@ -30,7 +31,7 @@ import java.util.Objects;
public class Arbitrator implements Serializable { public class Arbitrator implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -17,6 +17,8 @@
package io.bitsquare.arbitration; package io.bitsquare.arbitration;
import io.bitsquare.app.Version;
import java.io.Serializable; import java.io.Serializable;
//TODO still open if we use that really... //TODO still open if we use that really...
@ -26,7 +28,7 @@ import java.io.Serializable;
*/ */
public class Reputation implements Serializable { public class Reputation implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
//TODO //TODO
public Reputation() { public Reputation() {

View file

@ -17,6 +17,8 @@
package io.bitsquare.btc; package io.bitsquare.btc;
import io.bitsquare.app.Version;
import org.bitcoinj.core.Address; import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters; import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.crypto.DeterministicKey; import org.bitcoinj.crypto.DeterministicKey;
@ -31,9 +33,9 @@ import org.jetbrains.annotations.NotNull;
*/ */
public class AddressEntry implements Serializable { public class AddressEntry implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
// that will be restored from the wallet at deserialisation // that will be restored from the wallet at deserialization
private transient DeterministicKey keyPair; private transient DeterministicKey keyPair;
private final String offerId; private final String offerId;

View file

@ -17,6 +17,7 @@
package io.bitsquare.btc; package io.bitsquare.btc;
import io.bitsquare.app.Version;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import org.bitcoinj.core.Wallet; import org.bitcoinj.core.Wallet;
@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
public class AddressEntryList extends ArrayList<AddressEntry> implements Serializable { public class AddressEntryList extends ArrayList<AddressEntry> implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(AddressEntryList.class); transient private static final Logger log = LoggerFactory.getLogger(AddressEntryList.class);
final transient private Storage<AddressEntryList> storage; final transient private Storage<AddressEntryList> storage;

View file

@ -17,6 +17,8 @@
package io.bitsquare.crypto; package io.bitsquare.crypto;
import io.bitsquare.app.Version;
import java.io.Serializable; import java.io.Serializable;
import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.Immutable;
@ -24,7 +26,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class Bucket implements Serializable { public class Bucket implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final byte[] encryptedKey; public final byte[] encryptedKey;
public final byte[] encryptedPayload; public final byte[] encryptedPayload;

View file

@ -17,6 +17,8 @@
package io.bitsquare.crypto; package io.bitsquare.crypto;
import io.bitsquare.app.Version;
import java.io.Serializable; import java.io.Serializable;
import java.security.KeyFactory; import java.security.KeyFactory;
@ -37,7 +39,7 @@ import org.slf4j.LoggerFactory;
*/ */
public class PubKeyRing implements Serializable { public class PubKeyRing implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final Logger log = LoggerFactory.getLogger(PubKeyRing.class); private static final Logger log = LoggerFactory.getLogger(PubKeyRing.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.crypto; package io.bitsquare.crypto;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Message; import io.bitsquare.p2p.Message;
import java.io.Serializable; import java.io.Serializable;
@ -35,7 +36,7 @@ import javax.crypto.SealedObject;
*/ */
public class SealedAndSignedMessage implements Serializable, Message { public class SealedAndSignedMessage implements Serializable, Message {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
private static final Logger log = LoggerFactory.getLogger(SealedAndSignedMessage.class); private static final Logger log = LoggerFactory.getLogger(SealedAndSignedMessage.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.fiat; package io.bitsquare.fiat;
import io.bitsquare.app.Version;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import java.io.Serializable; import java.io.Serializable;
@ -30,7 +31,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class FiatAccount implements Serializable { public class FiatAccount implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public static final long HOUR_IN_BLOCKS = 6; public static final long HOUR_IN_BLOCKS = 6;
public static final long DAY_IN_BLOCKS = HOUR_IN_BLOCKS * 24; public static final long DAY_IN_BLOCKS = HOUR_IN_BLOCKS * 24;

View file

@ -17,6 +17,8 @@
package io.bitsquare.locale; package io.bitsquare.locale;
import io.bitsquare.app.Version;
import java.io.Serializable; import java.io.Serializable;
import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.Immutable;
@ -24,7 +26,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class Country implements Serializable { public class Country implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final String code; public final String code;
public final String name; public final String name;

View file

@ -17,6 +17,8 @@
package io.bitsquare.locale; package io.bitsquare.locale;
import io.bitsquare.app.Version;
import java.io.Serializable; import java.io.Serializable;
import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.Immutable;
@ -24,7 +26,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class Region implements Serializable { public class Region implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final String code; public final String code;
public final String name; public final String name;

View file

@ -17,6 +17,7 @@
package io.bitsquare.p2p.tomp2p; package io.bitsquare.p2p.tomp2p;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Peer; import io.bitsquare.p2p.Peer;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -35,7 +36,7 @@ import net.tomp2p.peers.PeerAddress;
@Immutable @Immutable
public class TomP2PPeer implements Peer, Serializable { public class TomP2PPeer implements Peer, Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private final PeerAddress peerAddress; private final PeerAddress peerAddress;

View file

@ -55,6 +55,16 @@ public class Storage<T extends Serializable> {
private static final Logger log = LoggerFactory.getLogger(Storage.class); private static final Logger log = LoggerFactory.getLogger(Storage.class);
public static final String DIR_KEY = "storage.dir"; public static final String DIR_KEY = "storage.dir";
private static DataBaseCorruptionHandler databaseCorruptionHandler;
public static void setDatabaseCorruptionHandler(DataBaseCorruptionHandler databaseCorruptionHandler) {
Storage.databaseCorruptionHandler = databaseCorruptionHandler;
}
public interface DataBaseCorruptionHandler {
void onFileCorrupted(String fileName);
}
private final File dir; private final File dir;
private FileManager<T> fileManager; private FileManager<T> fileManager;
private File storageFile; private File storageFile;
@ -120,7 +130,8 @@ public class Storage<T extends Serializable> {
log.info("Backup {} completed in {}msec", serializable.getClass().getSimpleName(), System.currentTimeMillis() - now); log.info("Backup {} completed in {}msec", serializable.getClass().getSimpleName(), System.currentTimeMillis() - now);
return persistedObject; return persistedObject;
} catch (InvalidClassException e) { } catch (InvalidClassException | ClassCastException | ClassNotFoundException 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 " + log.error("Version of persisted class has changed. We cannot read the persisted data anymore. We make a backup and remove the inconsistent " +
"file."); "file.");
try { try {
@ -131,10 +142,11 @@ public class Storage<T extends Serializable> {
log.error(e1.getMessage()); log.error(e1.getMessage());
// We swallow Exception if backup fails // We swallow Exception if backup fails
} }
} catch (IOException | ClassNotFoundException e) { databaseCorruptionHandler.onFileCorrupted(storageFile.getName());
e.printStackTrace(); } catch (Throwable throwable) {
log.error(e.getMessage()); throwable.printStackTrace();
Throwables.propagate(e); log.error(throwable.getMessage());
Throwables.propagate(throwable);
} }
} }
return null; return null;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Peer; import io.bitsquare.p2p.Peer;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.trade.offer.Offer; import io.bitsquare.trade.offer.Offer;
@ -35,7 +36,7 @@ import org.slf4j.LoggerFactory;
public class BuyerAsOffererTrade extends BuyerTrade implements OffererTrade, Serializable { public class BuyerAsOffererTrade extends BuyerTrade implements OffererTrade, Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(BuyerAsOffererTrade.class); transient private static final Logger log = LoggerFactory.getLogger(BuyerAsOffererTrade.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Peer; import io.bitsquare.p2p.Peer;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.trade.offer.Offer; import io.bitsquare.trade.offer.Offer;
@ -34,7 +35,7 @@ import org.slf4j.LoggerFactory;
public class BuyerAsTakerTrade extends BuyerTrade implements TakerTrade, Serializable { public class BuyerAsTakerTrade extends BuyerTrade implements TakerTrade, Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(BuyerAsTakerTrade.class); transient private static final Logger log = LoggerFactory.getLogger(BuyerAsTakerTrade.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Peer; import io.bitsquare.p2p.Peer;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.trade.offer.Offer; import io.bitsquare.trade.offer.Offer;
@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
public abstract class BuyerTrade extends Trade implements Serializable { public abstract class BuyerTrade extends Trade implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(BuyerAsOffererTrade.class); transient private static final Logger log = LoggerFactory.getLogger(BuyerAsOffererTrade.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.app.Version;
import io.bitsquare.crypto.PubKeyRing; import io.bitsquare.crypto.PubKeyRing;
import io.bitsquare.fiat.FiatAccount; import io.bitsquare.fiat.FiatAccount;
import io.bitsquare.trade.offer.Offer; import io.bitsquare.trade.offer.Offer;
@ -31,7 +32,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class Contract implements Serializable { public class Contract implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final Offer offer; public final Offer offer;
public final String takeOfferFeeTxID; public final String takeOfferFeeTxID;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Peer; import io.bitsquare.p2p.Peer;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.trade.offer.Offer; import io.bitsquare.trade.offer.Offer;
@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
public class SellerAsOffererTrade extends SellerTrade implements OffererTrade, Serializable { public class SellerAsOffererTrade extends SellerTrade implements OffererTrade, Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(SellerAsOffererTrade.class); transient private static final Logger log = LoggerFactory.getLogger(SellerAsOffererTrade.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Peer; import io.bitsquare.p2p.Peer;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.trade.offer.Offer; import io.bitsquare.trade.offer.Offer;
@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
public class SellerAsTakerTrade extends SellerTrade implements TakerTrade, Serializable { public class SellerAsTakerTrade extends SellerTrade implements TakerTrade, Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(SellerAsTakerTrade.class); transient private static final Logger log = LoggerFactory.getLogger(SellerAsTakerTrade.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Peer; import io.bitsquare.p2p.Peer;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.trade.offer.Offer; import io.bitsquare.trade.offer.Offer;
@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
public abstract class SellerTrade extends Trade implements Serializable { public abstract class SellerTrade extends Trade implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(BuyerAsTakerTrade.class); transient private static final Logger log = LoggerFactory.getLogger(BuyerAsTakerTrade.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.app.Version;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import java.io.IOException; import java.io.IOException;
@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
public class TradableList<T extends Tradable> extends ArrayList<T> implements Serializable { public class TradableList<T extends Tradable> extends ArrayList<T> implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(TradableList.class); transient private static final Logger log = LoggerFactory.getLogger(TradableList.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.app.Version;
import io.bitsquare.arbitration.ArbitrationRepository; import io.bitsquare.arbitration.ArbitrationRepository;
import io.bitsquare.btc.BlockChainService; import io.bitsquare.btc.BlockChainService;
import io.bitsquare.btc.TradeWalletService; import io.bitsquare.btc.TradeWalletService;
@ -68,7 +69,7 @@ import org.slf4j.LoggerFactory;
*/ */
abstract public class Trade implements Tradable, Model, Serializable { abstract public class Trade implements Tradable, Model, Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
private transient static final Logger log = LoggerFactory.getLogger(Trade.class); private transient static final Logger log = LoggerFactory.getLogger(Trade.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.offer; package io.bitsquare.trade.offer;
import io.bitsquare.app.Version;
import io.bitsquare.btc.Restrictions; import io.bitsquare.btc.Restrictions;
import io.bitsquare.common.handlers.ResultHandler; import io.bitsquare.common.handlers.ResultHandler;
import io.bitsquare.crypto.KeyRing; import io.bitsquare.crypto.KeyRing;
@ -48,7 +49,7 @@ import static com.google.common.base.Preconditions.*;
public class Offer implements Serializable { public class Offer implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(Offer.class); transient private static final Logger log = LoggerFactory.getLogger(Offer.class);
public enum Direction {BUY, SELL} public enum Direction {BUY, SELL}

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.offer; package io.bitsquare.trade.offer;
import io.bitsquare.app.Version;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import io.bitsquare.trade.Tradable; import io.bitsquare.trade.Tradable;
import io.bitsquare.trade.TradableList; import io.bitsquare.trade.TradableList;
@ -34,7 +35,7 @@ import org.slf4j.LoggerFactory;
public class OpenOffer implements Tradable, Serializable { public class OpenOffer implements Tradable, Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
private static final Logger log = LoggerFactory.getLogger(OpenOffer.class); private static final Logger log = LoggerFactory.getLogger(OpenOffer.class);

View file

@ -17,13 +17,14 @@
package io.bitsquare.trade.protocol.availability.messages; package io.bitsquare.trade.protocol.availability.messages;
import io.bitsquare.app.Version;
import io.bitsquare.crypto.PubKeyRing; import io.bitsquare.crypto.PubKeyRing;
import java.io.Serializable; import java.io.Serializable;
public class OfferAvailabilityRequest extends OfferMessage implements Serializable { public class OfferAvailabilityRequest extends OfferMessage implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private final PubKeyRing pubKeyRing; private final PubKeyRing pubKeyRing;

View file

@ -17,11 +17,13 @@
package io.bitsquare.trade.protocol.availability.messages; package io.bitsquare.trade.protocol.availability.messages;
import io.bitsquare.app.Version;
import java.io.Serializable; import java.io.Serializable;
public class OfferAvailabilityResponse extends OfferMessage implements Serializable { public class OfferAvailabilityResponse extends OfferMessage implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final boolean isAvailable; public final boolean isAvailable;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.availability.messages; package io.bitsquare.trade.protocol.availability.messages;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Message; import io.bitsquare.p2p.Message;
import java.io.Serializable; import java.io.Serializable;
@ -26,7 +27,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public abstract class OfferMessage implements Message, Serializable { public abstract class OfferMessage implements Message, Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final String offerId; public final String offerId;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade; package io.bitsquare.trade.protocol.trade;
import io.bitsquare.app.Version;
import io.bitsquare.arbitration.ArbitrationRepository; import io.bitsquare.arbitration.ArbitrationRepository;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.BlockChainService; import io.bitsquare.btc.BlockChainService;
@ -50,7 +51,7 @@ import org.slf4j.LoggerFactory;
public class ProcessModel implements Model, Serializable { public class ProcessModel implements Model, Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
private static final Logger log = LoggerFactory.getLogger(ProcessModel.class); private static final Logger log = LoggerFactory.getLogger(ProcessModel.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade; package io.bitsquare.trade.protocol.trade;
import io.bitsquare.app.Version;
import io.bitsquare.crypto.PubKeyRing; import io.bitsquare.crypto.PubKeyRing;
import io.bitsquare.fiat.FiatAccount; import io.bitsquare.fiat.FiatAccount;
@ -34,7 +35,7 @@ import org.slf4j.LoggerFactory;
public class TradingPeer implements Serializable { public class TradingPeer implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(TradingPeer.class); transient private static final Logger log = LoggerFactory.getLogger(TradingPeer.class);

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade.messages; package io.bitsquare.trade.protocol.trade.messages;
import io.bitsquare.app.Version;
import io.bitsquare.crypto.PubKeyRing; import io.bitsquare.crypto.PubKeyRing;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
@ -28,7 +29,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class DepositTxInputsRequest extends TradeMessage implements Serializable { public class DepositTxInputsRequest extends TradeMessage implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final Coin tradeAmount; public final Coin tradeAmount;
public final PubKeyRing sellerPubKeyRing; public final PubKeyRing sellerPubKeyRing;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade.messages; package io.bitsquare.trade.protocol.trade.messages;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.MailboxMessage; import io.bitsquare.p2p.MailboxMessage;
import org.bitcoinj.core.Transaction; import org.bitcoinj.core.Transaction;
@ -28,7 +29,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class DepositTxPublishedMessage extends TradeMessage implements MailboxMessage, Serializable { public class DepositTxPublishedMessage extends TradeMessage implements MailboxMessage, Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final Transaction depositTx; public final Transaction depositTx;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade.messages; package io.bitsquare.trade.protocol.trade.messages;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.MailboxMessage; import io.bitsquare.p2p.MailboxMessage;
import java.io.Serializable; import java.io.Serializable;
@ -26,7 +27,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class FiatTransferStartedMessage extends TradeMessage implements MailboxMessage, Serializable { public class FiatTransferStartedMessage extends TradeMessage implements MailboxMessage, Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final String buyerPayoutAddress; public final String buyerPayoutAddress;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade.messages; package io.bitsquare.trade.protocol.trade.messages;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.MailboxMessage; import io.bitsquare.p2p.MailboxMessage;
import java.io.Serializable; import java.io.Serializable;
@ -26,7 +27,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class FinalizePayoutTxRequest extends TradeMessage implements MailboxMessage, Serializable { public class FinalizePayoutTxRequest extends TradeMessage implements MailboxMessage, Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final byte[] sellerSignature; public final byte[] sellerSignature;
public final String sellerPayoutAddress; public final String sellerPayoutAddress;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade.messages; package io.bitsquare.trade.protocol.trade.messages;
import io.bitsquare.app.Version;
import io.bitsquare.crypto.PubKeyRing; import io.bitsquare.crypto.PubKeyRing;
import io.bitsquare.fiat.FiatAccount; import io.bitsquare.fiat.FiatAccount;
@ -32,7 +33,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class PayDepositRequest extends TradeMessage implements Serializable { public class PayDepositRequest extends TradeMessage implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final List<TransactionOutput> buyerConnectedOutputsForAllInputs; public final List<TransactionOutput> buyerConnectedOutputsForAllInputs;
public final List<TransactionOutput> buyerOutputs; public final List<TransactionOutput> buyerOutputs;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade.messages; package io.bitsquare.trade.protocol.trade.messages;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.MailboxMessage; import io.bitsquare.p2p.MailboxMessage;
import org.bitcoinj.core.Transaction; import org.bitcoinj.core.Transaction;
@ -28,7 +29,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class PayoutTxFinalizedMessage extends TradeMessage implements MailboxMessage, Serializable { public class PayoutTxFinalizedMessage extends TradeMessage implements MailboxMessage, Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final Transaction payoutTx; public final Transaction payoutTx;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade.messages; package io.bitsquare.trade.protocol.trade.messages;
import io.bitsquare.app.Version;
import io.bitsquare.fiat.FiatAccount; import io.bitsquare.fiat.FiatAccount;
import org.bitcoinj.core.Transaction; import org.bitcoinj.core.Transaction;
@ -31,7 +32,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public class PublishDepositTxRequest extends TradeMessage implements Serializable { public class PublishDepositTxRequest extends TradeMessage implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final FiatAccount sellerFiatAccount; public final FiatAccount sellerFiatAccount;
public final String sellerAccountId; public final String sellerAccountId;

View file

@ -17,6 +17,7 @@
package io.bitsquare.trade.protocol.trade.messages; package io.bitsquare.trade.protocol.trade.messages;
import io.bitsquare.app.Version;
import io.bitsquare.p2p.Message; import io.bitsquare.p2p.Message;
import java.io.Serializable; import java.io.Serializable;
@ -26,7 +27,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
public abstract class TradeMessage implements Message, Serializable { public abstract class TradeMessage implements Message, Serializable {
// That object is sent over the wire, so we need to take care of version compatibility. // That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public final String tradeId; public final String tradeId;

View file

@ -17,6 +17,7 @@
package io.bitsquare.user; package io.bitsquare.user;
import io.bitsquare.app.Version;
import io.bitsquare.arbitration.ArbitrationRepository; import io.bitsquare.arbitration.ArbitrationRepository;
import io.bitsquare.arbitration.Arbitrator; import io.bitsquare.arbitration.Arbitrator;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
@ -38,7 +39,7 @@ import javax.inject.Inject;
public class AccountSettings implements Serializable { public class AccountSettings implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
final transient private Storage<AccountSettings> storage; final transient private Storage<AccountSettings> storage;

View file

@ -17,6 +17,7 @@
package io.bitsquare.user; package io.bitsquare.user;
import io.bitsquare.app.Version;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import org.bitcoinj.utils.MonetaryFormat; import org.bitcoinj.utils.MonetaryFormat;
@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory;
public class Preferences implements Serializable { public class Preferences implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(Preferences.class); transient private static final Logger log = LoggerFactory.getLogger(Preferences.class);

View file

@ -17,9 +17,12 @@
package io.bitsquare.user; package io.bitsquare.user;
import io.bitsquare.app.Version;
import io.bitsquare.fiat.FiatAccount; import io.bitsquare.fiat.FiatAccount;
import io.bitsquare.storage.Storage; import io.bitsquare.storage.Storage;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable; import java.io.Serializable;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@ -46,7 +49,7 @@ import org.slf4j.LoggerFactory;
*/ */
public class User implements Serializable { public class User implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(User.class); transient private static final Logger log = LoggerFactory.getLogger(User.class);
@ -56,6 +59,7 @@ public class User implements Serializable {
// Persisted fields // Persisted fields
private String accountID; private String accountID;
private List<FiatAccount> fiatAccounts = new ArrayList<>(); private List<FiatAccount> fiatAccounts = new ArrayList<>();
private FiatAccount currentFiatAccount; private FiatAccount currentFiatAccount;
// Observable wrappers // Observable wrappers
@ -94,6 +98,12 @@ public class User implements Serializable {
} }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
log.trace("Created from serialized form.");
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Public Methods // Public Methods
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -22,10 +22,10 @@ import io.bitsquare.gui.common.view.CachingViewLoader;
import io.bitsquare.gui.common.view.View; import io.bitsquare.gui.common.view.View;
import io.bitsquare.gui.common.view.ViewLoader; import io.bitsquare.gui.common.view.ViewLoader;
import io.bitsquare.gui.common.view.guice.InjectorViewFactory; import io.bitsquare.gui.common.view.guice.InjectorViewFactory;
import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.main.MainView; import io.bitsquare.gui.main.MainView;
import io.bitsquare.gui.main.debug.DebugView; import io.bitsquare.gui.main.debug.DebugView;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.storage.Storage;
import io.bitsquare.util.Utilities; import io.bitsquare.util.Utilities;
import org.bitcoinj.utils.Threading; import org.bitcoinj.utils.Threading;
@ -35,15 +35,21 @@ import com.google.inject.Injector;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javafx.application.Application; import javafx.application.Application;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.*; import javafx.scene.*;
import javafx.scene.image.*; import javafx.scene.image.*;
import javafx.scene.input.*; import javafx.scene.input.*;
import javafx.scene.layout.*;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.StageStyle; import javafx.stage.StageStyle;
import org.controlsfx.dialog.Dialogs;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.Logger;
@ -60,6 +66,8 @@ public class BitsquareApp extends Application {
private Injector injector; private Injector injector;
private Stage primaryStage; private Stage primaryStage;
private Scene scene; private Scene scene;
private List<String> corruptedDatabaseFiles = new ArrayList<>();
private MainView mainView;
public static void setEnvironment(Environment env) { public static void setEnvironment(Environment env) {
BitsquareApp.env = env; BitsquareApp.env = env;
@ -68,6 +76,15 @@ public class BitsquareApp extends Application {
@Override @Override
public void start(Stage primaryStage) throws IOException { public void start(Stage primaryStage) throws IOException {
this.primaryStage = primaryStage; this.primaryStage = primaryStage;
// setup UncaughtExceptionHandler
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
// Might come from another thread
Platform.runLater(() -> showErrorPopup(throwable, true));
};
Thread.setDefaultUncaughtExceptionHandler(handler);
Thread.currentThread().setUncaughtExceptionHandler(handler);
try { try {
log.trace("BitsquareApp.start"); log.trace("BitsquareApp.start");
@ -80,6 +97,12 @@ public class BitsquareApp extends Application {
URI.create("http://188.226.179.109/crashfx/upload"));*/ URI.create("http://188.226.179.109/crashfx/upload"));*/
// Server not setup yet, so we use client side only support // Server not setup yet, so we use client side only support
Storage.setDatabaseCorruptionHandler((String fileName) -> {
corruptedDatabaseFiles.add(fileName);
if (mainView != null)
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
});
// Guice // Guice
bitsquareAppModule = new BitsquareAppModule(env, primaryStage); bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
injector = Guice.createInjector(bitsquareAppModule); injector = Guice.createInjector(bitsquareAppModule);
@ -87,10 +110,11 @@ public class BitsquareApp extends Application {
// load the main view and create the main scene // load the main view and create the main scene
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class); CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
MainView view = (MainView) viewLoader.load(MainView.class); mainView = (MainView) viewLoader.load(MainView.class);
view.setExitHandler(this::stop); mainView.setExitHandler(this::stop);
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
scene = new Scene(view.getRoot(), 1000, 650); scene = new Scene(mainView.getRoot(), 1000, 650);
scene.getStylesheets().setAll( scene.getStylesheets().setAll(
"/io/bitsquare/gui/bitsquare.css", "/io/bitsquare/gui/bitsquare.css",
"/io/bitsquare/gui/images.css"); "/io/bitsquare/gui/images.css");
@ -135,8 +159,37 @@ public class BitsquareApp extends Application {
//TODO just temp. //TODO just temp.
//showDebugWindow(); //showDebugWindow();
} catch (Throwable t) { } catch (Throwable throwable) {
Popups.openExceptionPopup(t); showErrorPopup(throwable, true);
}
}
private void showErrorPopup(Throwable throwable, boolean doShutDown) {
if (scene == null) {
scene = new Scene(new StackPane(), 1000, 650);
primaryStage.setScene(scene);
primaryStage.show();
}
try {
throwable.printStackTrace();
Dialogs.create()
.owner(primaryStage)
.title("")
.message("")
.masthead("")
.showException(throwable);
if (doShutDown)
stop();
} catch (Throwable throwable2) {
// If printStackTrace cause a further exception we don't pass the throwable to the Popup.
Dialogs.create()
.owner(primaryStage)
.title("Error")
.message(throwable.toString())
.masthead("A fatal exception occurred at startup.")
.showError();
if (doShutDown)
stop();
} }
} }

View file

@ -17,6 +17,7 @@
package io.bitsquare.gui; package io.bitsquare.gui;
import io.bitsquare.app.Version;
import io.bitsquare.gui.common.view.View; import io.bitsquare.gui.common.view.View;
import io.bitsquare.gui.common.view.ViewPath; import io.bitsquare.gui.common.view.ViewPath;
import io.bitsquare.gui.main.MainView; import io.bitsquare.gui.main.MainView;
@ -36,7 +37,7 @@ import org.slf4j.LoggerFactory;
public class Navigation implements Serializable { public class Navigation implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
transient private static final Logger log = LoggerFactory.getLogger(Navigation.class); transient private static final Logger log = LoggerFactory.getLogger(Navigation.class);
transient private static final ViewPath DEFAULT_VIEW_PATH = ViewPath.to(MainView.class, BuyOfferView.class); transient private static final ViewPath DEFAULT_VIEW_PATH = ViewPath.to(MainView.class, BuyOfferView.class);

View file

@ -17,6 +17,8 @@
package io.bitsquare.gui.common.view; package io.bitsquare.gui.common.view;
import io.bitsquare.app.Version;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
@ -26,7 +28,7 @@ import java.util.List;
public class ViewPath extends ArrayList<Class<? extends View>> implements Serializable { public class ViewPath extends ArrayList<Class<? extends View>> implements Serializable {
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = 1L; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
public ViewPath() { public ViewPath() {
} }

View file

@ -38,6 +38,8 @@ import io.bitsquare.gui.main.portfolio.PortfolioView;
import io.bitsquare.gui.main.settings.SettingsView; import io.bitsquare.gui.main.settings.SettingsView;
import io.bitsquare.gui.util.Transitions; import io.bitsquare.gui.util.Transitions;
import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -80,6 +82,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
private Label blockchainSyncLabel; private Label blockchainSyncLabel;
private Label updateInfoLabel; private Label updateInfoLabel;
private Runnable exitHandler; private Runnable exitHandler;
private List<String> persistedFilesCorrupted;
@Inject @Inject
public MainView(MainViewModel model, CachingViewLoader viewLoader, Navigation navigation, OverlayManager overlayManager, Transitions transitions, public MainView(MainViewModel model, CachingViewLoader viewLoader, Navigation navigation, OverlayManager overlayManager, Transitions transitions,
@ -170,6 +173,15 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
navigation.navigateToPreviousVisitedView(); navigation.navigateToPreviousVisitedView();
if (!persistedFilesCorrupted.isEmpty()) {
// show warning that some files has been corrupted
Popups.openWarningPopup("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"
);
}
transitions.fadeOutAndRemove(splashScreen, 1500, actionEvent -> disposeSplashScreen()); transitions.fadeOutAndRemove(splashScreen, 1500, actionEvent -> disposeSplashScreen());
} }
}); });
@ -182,6 +194,10 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
this.exitHandler = exitHandler; this.exitHandler = exitHandler;
} }
public void setPersistedFilesCorrupted(List<String> persistedFilesCorrupted) {
this.persistedFilesCorrupted = persistedFilesCorrupted;
}
private VBox createSplashScreen() { private VBox createSplashScreen() {
VBox vBox = new VBox(); VBox vBox = new VBox();
vBox.setAlignment(Pos.CENTER); vBox.setAlignment(Pos.CENTER);

View file

@ -34,6 +34,7 @@ class OpenOfferListItem {
public OpenOffer getOpenOffer() { public OpenOffer getOpenOffer() {
return openOffer; return openOffer;
} }
public Offer getOffer() { public Offer getOffer() {
return openOffer.getOffer(); return openOffer.getOffer();
} }