diff --git a/core/src/main/java/io/bitsquare/trade/Trade.java b/core/src/main/java/io/bitsquare/trade/Trade.java index acc31e1577..0cbe7e7eb8 100644 --- a/core/src/main/java/io/bitsquare/trade/Trade.java +++ b/core/src/main/java/io/bitsquare/trade/Trade.java @@ -52,6 +52,8 @@ import javax.annotation.Nullable; import java.io.IOException; import java.io.ObjectInputStream; import java.util.Date; +import java.util.HashSet; +import java.util.Set; /** * Holds all data which are relevant to the trade, but not those which are only needed in the trade process as shared data between tasks. Those data are @@ -170,6 +172,7 @@ public abstract class Trade implements Tradable, Model { transient private StringProperty errorMessageProperty; transient private ObjectProperty tradeAmountProperty; transient private ObjectProperty tradeVolumeProperty; + transient private Set mailboxMessageSet = new HashSet<>(); /////////////////////////////////////////////////////////////////////////////////////////// @@ -210,6 +213,7 @@ public abstract class Trade implements Tradable, Model { initStateProperties(); initAmountProperty(); errorMessageProperty = new SimpleStringProperty(errorMessage); + mailboxMessageSet = new HashSet<>(); } catch (Throwable t) { log.warn("Cannot be deserialized." + t.getMessage()); } @@ -242,10 +246,11 @@ public abstract class Trade implements Tradable, Model { createProtocol(); - log.trace("decryptedMsgWithPubKey = " + decryptedMsgWithPubKey); - if (decryptedMsgWithPubKey != null) + log.trace("init: decryptedMsgWithPubKey = " + decryptedMsgWithPubKey); + if (decryptedMsgWithPubKey != null && !mailboxMessageSet.contains(decryptedMsgWithPubKey)) { + mailboxMessageSet.add(decryptedMsgWithPubKey); tradeProtocol.applyMailboxMessage(decryptedMsgWithPubKey, this); - + } } protected void initStateProperties() { @@ -288,8 +293,13 @@ public abstract class Trade implements Tradable, Model { } public void setMailboxMessage(DecryptedMsgWithPubKey decryptedMsgWithPubKey) { - log.trace("setMailboxMessage " + decryptedMsgWithPubKey); + log.trace("setMailboxMessage decryptedMsgWithPubKey=" + decryptedMsgWithPubKey); this.decryptedMsgWithPubKey = decryptedMsgWithPubKey; + + if (tradeProtocol != null && decryptedMsgWithPubKey != null && !mailboxMessageSet.contains(decryptedMsgWithPubKey)) { + mailboxMessageSet.add(decryptedMsgWithPubKey); + tradeProtocol.applyMailboxMessage(decryptedMsgWithPubKey, this); + } } public DecryptedMsgWithPubKey getMailboxMessage() { @@ -309,7 +319,6 @@ public abstract class Trade implements Tradable, Model { this.state = state; stateProperty.set(state); persist(); - persist(); } public void setDisputeState(DisputeState disputeState) { diff --git a/core/src/main/java/io/bitsquare/trade/TradeManager.java b/core/src/main/java/io/bitsquare/trade/TradeManager.java index 3afcfb9832..197dba3c2d 100644 --- a/core/src/main/java/io/bitsquare/trade/TradeManager.java +++ b/core/src/main/java/io/bitsquare/trade/TradeManager.java @@ -158,6 +158,7 @@ public class TradeManager { } public void onAllServicesInitialized() { + Log.traceCall(); if (p2PService.isBootstrapped()) initPendingTrades(); else diff --git a/gui/src/main/resources/logback.xml b/gui/src/main/resources/logback.xml index 4069a9cf4b..7b607ebf19 100644 --- a/gui/src/main/resources/logback.xml +++ b/gui/src/main/resources/logback.xml @@ -27,7 +27,7 @@ - +