mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-10-12 02:20:53 -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() {
|
public void onShutDownStarted() {
|
||||||
if (wallet != null) log.info("Preparing to shut down {} {}", getClass().getSimpleName(), getId());
|
if (!isShutDownStarted) {
|
||||||
isShutDownStarted = true;
|
if (wallet != null) log.info("Preparing to shut down {} {}", getClass().getSimpleName(), getId());
|
||||||
stopPolling();
|
isShutDownStarted = true;
|
||||||
|
stopPolling();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutDown() {
|
public void shutDown() {
|
||||||
if (isShutDown) return; // ignore if already shut down
|
if (isShutDown) return; // ignore if already shut down
|
||||||
isShutDownStarted = true;
|
onShutDownStarted();
|
||||||
if (!isPayoutFinalized()) log.info("Shutting down {} {}", getClass().getSimpleName(), getId());
|
if (!isPayoutFinalized()) log.info("Shutting down {} {}", getClass().getSimpleName(), getId());
|
||||||
|
|
||||||
// unregister p2p message listener
|
// 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)
|
// If trade is in already in critical state (if taker role: taker fee; both roles: after deposit published)
|
||||||
// we move the trade to FailedTradesManager
|
// we move the trade to FailedTradesManager
|
||||||
public void onMoveInvalidTradeToFailedTrades(Trade trade) {
|
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);
|
failedTradesManager.add(trade);
|
||||||
removeTrade(trade);
|
removeTrade(trade);
|
||||||
xmrWalletService.fixReservedOutputs();
|
xmrWalletService.fixReservedOutputs();
|
||||||
|
@ -1125,11 +1134,13 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
||||||
|
|
||||||
private void addTradeToPendingTrades(Trade trade) {
|
private void addTradeToPendingTrades(Trade trade) {
|
||||||
if (!trade.isInitialized()) {
|
if (!trade.isInitialized()) {
|
||||||
try {
|
ThreadUtils.execute(() -> {
|
||||||
initTrade(trade);
|
try {
|
||||||
} catch (Exception e) {
|
initTrade(trade);
|
||||||
log.warn("Error initializing {} {} on move to pending trades", trade.getClass().getSimpleName(), trade.getShortId(), e);
|
} catch (Exception e) {
|
||||||
}
|
log.warn("Error initializing {} {} on move to pending trades", trade.getClass().getSimpleName(), trade.getShortId(), e);
|
||||||
|
}
|
||||||
|
}, trade.getId() + "_init");
|
||||||
}
|
}
|
||||||
addTrade(trade);
|
addTrade(trade);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue