diff --git a/common/src/main/java/haveno/common/persistence/PersistenceManager.java b/common/src/main/java/haveno/common/persistence/PersistenceManager.java index 9804798bbd..7bdb4cb1e7 100644 --- a/common/src/main/java/haveno/common/persistence/PersistenceManager.java +++ b/common/src/main/java/haveno/common/persistence/PersistenceManager.java @@ -413,6 +413,11 @@ public class PersistenceManager { public void requestPersistence() { if (flushAtShutdownCalled) { log.warn("We have started the shut down routine already. We ignore that requestPersistence call."); + try { + throw new RuntimeException("We have started the shut down routine already. We ignore that requestPersistence call."); + } catch (Exception e) { + e.printStackTrace(); + } return; } diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index cc6e68a541..5bab5c8331 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -1359,6 +1359,15 @@ public abstract class Trade implements Tradable, Model { throw new RuntimeException("Trade is not maker, taker, or arbitrator"); } + private List getPeers() { + List peers = new ArrayList(); + peers.add(getMaker()); + peers.add(getTaker()); + peers.add(getArbitrator()); + if (!peers.remove(getSelf())) throw new IllegalStateException("Failed to remove self from list of peers"); + return peers; + } + public TradePeer getArbitrator() { return processModel.getArbitrator(); } @@ -1522,6 +1531,16 @@ public abstract class Trade implements Tradable, Model { return isDepositsPublished() && getState().getPhase().ordinal() >= Phase.DEPOSITS_CONFIRMED.ordinal(); } + // TODO: hacky way to check for deposits confirmed acks, redundant with getDepositsConfirmedTasks() + public boolean isDepositsConfirmedAcked() { + if (this instanceof BuyerTrade) { + return getArbitrator().isDepositsConfirmedMessageAcked(); + } else { + for (TradePeer peer : getPeers()) if (!peer.isDepositsConfirmedMessageAcked()) return false; + return true; + } + } + public boolean isDepositsUnlocked() { return isDepositsPublished() && getState().getPhase().ordinal() >= Phase.DEPOSITS_UNLOCKED.ordinal(); } diff --git a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java index 0367081b8a..7ab3f1c1b8 100644 --- a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java @@ -863,9 +863,9 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D } public void maybeSendDepositsConfirmedMessages() { - if (trade.isShutDownStarted()) return; synchronized (trade) { - if (!trade.isInitialized()) return; // skip if shutting down + if (trade.isDepositsConfirmedAcked()) return; + if (!trade.isInitialized() || trade.isShutDownStarted()) return; // skip if shutting down latchTrade(); expect(new Condition(trade)) .setup(tasks(getDepositsConfirmedTasks())