stop initializing trades on shutdown

This commit is contained in:
woodser 2022-11-26 17:23:11 +00:00
parent 7062fa9e79
commit e20e23dbc5

View File

@ -118,6 +118,7 @@ import monero.wallet.model.MoneroOutputQuery;
public class TradeManager implements PersistedDataHost, DecryptedDirectMessageListener { public class TradeManager implements PersistedDataHost, DecryptedDirectMessageListener {
private static final Logger log = LoggerFactory.getLogger(TradeManager.class); private static final Logger log = LoggerFactory.getLogger(TradeManager.class);
private boolean isShutDown;
private final User user; private final User user;
@Getter @Getter
private final KeyRing keyRing; private final KeyRing keyRing;
@ -271,6 +272,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
} }
public void shutDown() { public void shutDown() {
isShutDown = true;
// collect trades to shutdown // collect trades to shutdown
Set<Trade> trades = new HashSet<Trade>(); Set<Trade> trades = new HashSet<Trade>();
@ -360,6 +362,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
HavenoUtils.executeTasks(tasks, threadPoolSize); HavenoUtils.executeTasks(tasks, threadPoolSize);
// reset any available address entries // reset any available address entries
if (isShutDown) return;
xmrWalletService.getAddressEntriesForAvailableBalanceStream() xmrWalletService.getAddressEntriesForAvailableBalanceStream()
.filter(addressEntry -> addressEntry.getOfferId() != null) .filter(addressEntry -> addressEntry.getOfferId() != null)
.forEach(addressEntry -> { .forEach(addressEntry -> {
@ -378,6 +381,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
} }
private void initPersistedTrade(Trade trade) { private void initPersistedTrade(Trade trade) {
if (isShutDown) return;
initTradeAndProtocol(trade, getTradeProtocol(trade)); initTradeAndProtocol(trade, getTradeProtocol(trade));
requestPersistence(); requestPersistence();
} }