From 567ef6784dbbc693e02b977ace213011deab4537 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 19 Apr 2023 13:51:43 -0400 Subject: [PATCH] tradeManager error handling uses getOpenTradeByUid() --- core/src/main/java/haveno/core/trade/TradeManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index e5072d53e0..8a3a10be59 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -414,7 +414,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi initPersistedTrade(trade); // remove trade if protocol didn't initialize - if (getOpenTrade(trade.getId()).isPresent() && !trade.isDepositRequested()) { + if (getOpenTradeByUid(trade.getId()).isPresent() && !trade.isDepositRequested()) { log.warn("Removing persisted {} {} with uid={} because it did not finish initializing (state={})", trade.getClass().getSimpleName(), trade.getId(), trade.getUid(), trade.getState()); maybeRemoveTradeOnError(trade); } @@ -1137,6 +1137,12 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi } } + public Optional getOpenTradeByUid(String tradeUid) { + synchronized (tradableList) { + return tradableList.stream().filter(e -> e.getUid().equals(tradeUid)).findFirst(); + } + } + public List getAllTrades() { List trades = new ArrayList(); trades.addAll(tradableList.getList());