mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-10-11 01:58:47 -04:00
shut down trade when moved to failed
This commit is contained in:
parent
9b179f4b10
commit
7779236f24
2 changed files with 22 additions and 9 deletions
|
@ -1733,14 +1733,16 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
|||
}
|
||||
|
||||
public void onShutDownStarted() {
|
||||
if (wallet != null) log.info("Preparing to shut down {} {}", getClass().getSimpleName(), getId());
|
||||
isShutDownStarted = true;
|
||||
stopPolling();
|
||||
if (!isShutDownStarted) {
|
||||
if (wallet != null) log.info("Preparing to shut down {} {}", getClass().getSimpleName(), getId());
|
||||
isShutDownStarted = true;
|
||||
stopPolling();
|
||||
}
|
||||
}
|
||||
|
||||
public void shutDown() {
|
||||
if (isShutDown) return; // ignore if already shut down
|
||||
isShutDownStarted = true;
|
||||
onShutDownStarted();
|
||||
if (!isPayoutFinalized()) log.info("Shutting down {} {}", getClass().getSimpleName(), getId());
|
||||
|
||||
// unregister p2p message listener
|
||||
|
|
|
@ -1102,6 +1102,15 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||
// If trade is in already in critical state (if taker role: taker fee; both roles: after deposit published)
|
||||
// we move the trade to FailedTradesManager
|
||||
public void onMoveInvalidTradeToFailedTrades(Trade trade) {
|
||||
if (trade.isInitialized()) {
|
||||
ThreadUtils.execute(() -> {
|
||||
try {
|
||||
trade.shutDown();
|
||||
} catch (Exception e) {
|
||||
log.warn("Error shutting down {} {} on move to failed trades", trade.getClass().getSimpleName(), trade.getShortId(), e);
|
||||
}
|
||||
}, trade.getId() + "_init");
|
||||
}
|
||||
failedTradesManager.add(trade);
|
||||
removeTrade(trade);
|
||||
xmrWalletService.fixReservedOutputs();
|
||||
|
@ -1125,11 +1134,13 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||
|
||||
private void addTradeToPendingTrades(Trade trade) {
|
||||
if (!trade.isInitialized()) {
|
||||
try {
|
||||
initTrade(trade);
|
||||
} catch (Exception e) {
|
||||
log.warn("Error initializing {} {} on move to pending trades", trade.getClass().getSimpleName(), trade.getShortId(), e);
|
||||
}
|
||||
ThreadUtils.execute(() -> {
|
||||
try {
|
||||
initTrade(trade);
|
||||
} catch (Exception e) {
|
||||
log.warn("Error initializing {} {} on move to pending trades", trade.getClass().getSimpleName(), trade.getShortId(), e);
|
||||
}
|
||||
}, trade.getId() + "_init");
|
||||
}
|
||||
addTrade(trade);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue