save and back up trade wallets off thread at key steps

This commit is contained in:
woodser 2023-04-21 09:31:07 -04:00
parent 37e812dead
commit a7ab31d44e
5 changed files with 11 additions and 2 deletions

View File

@ -1162,7 +1162,7 @@ public abstract class Trade implements Tradable, Model {
isShutDown = true;
synchronized (walletLock) {
if (wallet != null) {
saveWallet();
xmrWalletService.saveWallet(wallet, false); // skip backup
stopWallet();
}
}

View File

@ -70,6 +70,9 @@ public class BuyerPreparePaymentSentMessage extends TradeTask {
MoneroTxWallet payoutTx = trade.createPayoutTx();
trade.setPayoutTx(payoutTx);
trade.setPayoutTxHex(payoutTx.getTxSet().getMultisigTxHex());
// save wallet off thread
new Thread(() -> trade.saveWallet()).start();
}
complete();

View File

@ -69,6 +69,9 @@ public class ProcessDepositsConfirmedMessage extends TradeTask {
e.printStackTrace();
}
// save wallet off thread
new Thread(() -> trade.saveWallet()).start();
// persist and complete
processModel.getTradeManager().requestPersistence();
complete();

View File

@ -110,7 +110,7 @@ public class ProcessInitMultisigRequest extends TradeTask {
log.info("Importing exchanged multisig hex for trade {}", trade.getId());
MoneroMultisigInitResult result = multisigWallet.exchangeMultisigKeys(Arrays.asList(peers[0].getExchangedMultisigHex(), peers[1].getExchangedMultisigHex()), xmrWalletService.getWalletPassword());
processModel.setMultisigAddress(result.getAddress());
trade.saveWallet(); // save multisig wallet on completion
new Thread(() -> trade.saveWallet()).start(); // save multisig wallet off thread on completion
trade.setStateIfValidTransitionTo(Trade.State.MULTISIG_COMPLETED);
trade.updateWalletRefreshPeriod(); // starts syncing
}

View File

@ -69,6 +69,9 @@ public class ProcessPaymentSentMessage extends TradeTask {
e.printStackTrace();
}
// save wallet off thread
new Thread(() -> trade.saveWallet()).start();
// update state
trade.advanceState(Trade.State.BUYER_SENT_PAYMENT_SENT_MSG);
trade.requestPersistence();