improve reliability of requesting persistence and persisting trade state (#1921)

This commit is contained in:
woodser 2025-08-31 09:55:34 -04:00 committed by GitHub
parent afe4ba3ad8
commit 0c1e4f31af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 11 deletions

View file

@ -813,12 +813,14 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
while (!isFullyInitialized) HavenoUtils.waitFor(100); // TODO: use proper notification and refactor isInitialized, fullyInitialized, and arbitrator idling
}
// TODO: throw if trade manager is null
public void requestPersistence() {
if (processModel.getTradeManager() != null) processModel.getTradeManager().requestPersistence();
}
// TODO: throw if trade manager is null
public void persistNow(@Nullable Runnable completeHandler) {
processModel.getTradeManager().persistNow(completeHandler);
if (processModel.getTradeManager() != null) processModel.getTradeManager().persistNow(completeHandler);
}
public TradeProtocol getProtocol() {
@ -1099,7 +1101,6 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
synchronized (HavenoUtils.getWalletFunctionLock()) {
MoneroTxWallet tx = wallet.createTx(txConfig);
exportMultisigHex();
saveWallet();
return tx;
}
}
@ -1108,7 +1109,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
public void exportMultisigHex() {
synchronized (walletLock) {
getSelf().setUpdatedMultisigHex(wallet.exportMultisigHex());
requestPersistence();
saveWallet();
}
}
@ -1889,7 +1890,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
}
this.state = state;
requestPersistence();
persistNow(null);
UserThread.execute(() -> {
stateProperty.set(state);
phaseProperty.set(state.getPhase());
@ -1921,7 +1922,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
}
this.payoutState = payoutState;
requestPersistence();
persistNow(null);
UserThread.execute(() -> payoutStateProperty.set(payoutState));
}
@ -1937,6 +1938,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
}
this.disputeState = disputeState;
persistNow(null);
UserThread.execute(() -> {
disputeStateProperty.set(disputeState);
});