tradeManager error handling uses getOpenTradeByUid()

This commit is contained in:
woodser 2023-04-19 13:51:43 -04:00
parent 1d17330487
commit 567ef6784d

View File

@ -414,7 +414,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
initPersistedTrade(trade); initPersistedTrade(trade);
// remove trade if protocol didn't initialize // 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()); log.warn("Removing persisted {} {} with uid={} because it did not finish initializing (state={})", trade.getClass().getSimpleName(), trade.getId(), trade.getUid(), trade.getState());
maybeRemoveTradeOnError(trade); maybeRemoveTradeOnError(trade);
} }
@ -1137,6 +1137,12 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
} }
} }
public Optional<Trade> getOpenTradeByUid(String tradeUid) {
synchronized (tradableList) {
return tradableList.stream().filter(e -> e.getUid().equals(tradeUid)).findFirst();
}
}
public List<Trade> getAllTrades() { public List<Trade> getAllTrades() {
List<Trade> trades = new ArrayList<Trade>(); List<Trade> trades = new ArrayList<Trade>();
trades.addAll(tradableList.getList()); trades.addAll(tradableList.getList());