Skip to content

Commit b0837a1

Browse files
committed
improve reliability of requesting persistence including trade state
1 parent 3067609 commit b0837a1

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

common/src/main/java/haveno/common/persistence/PersistenceManager.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,14 @@ public void requestPersistence() {
433433
private void maybeStartTimerForPersistence() {
434434
// We write to disk with a delay to avoid frequent write operations. Depending on the priority those delays
435435
// can be rather long.
436-
if (timer == null) {
437-
timer = UserThread.runAfter(() -> {
438-
persistNow(null);
439-
UserThread.execute(() -> timer = null);
440-
}, source.delay, TimeUnit.MILLISECONDS);
441-
}
436+
UserThread.execute(() -> {
437+
if (timer == null) {
438+
timer = UserThread.runAfter(() -> {
439+
persistNow(null);
440+
UserThread.execute(() -> timer = null);
441+
}, source.delay, TimeUnit.MILLISECONDS);
442+
}
443+
});
442444
}
443445

444446
public void forcePersistNow() {

core/src/main/java/haveno/core/trade/Trade.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,6 @@ public MoneroTxWallet createTx(MoneroTxConfig txConfig) {
10981098
synchronized (HavenoUtils.getWalletFunctionLock()) {
10991099
MoneroTxWallet tx = wallet.createTx(txConfig);
11001100
exportMultisigHex();
1101-
saveWallet();
11021101
return tx;
11031102
}
11041103
}
@@ -1107,7 +1106,7 @@ public MoneroTxWallet createTx(MoneroTxConfig txConfig) {
11071106
public void exportMultisigHex() {
11081107
synchronized (walletLock) {
11091108
getSelf().setUpdatedMultisigHex(wallet.exportMultisigHex());
1110-
requestPersistence();
1109+
saveWallet();
11111110
}
11121111
}
11131112

@@ -1888,7 +1887,7 @@ public void setState(State state) {
18881887
}
18891888

18901889
this.state = state;
1891-
requestPersistence();
1890+
persistNow(null);
18921891
UserThread.execute(() -> {
18931892
stateProperty.set(state);
18941893
phaseProperty.set(state.getPhase());
@@ -1920,7 +1919,7 @@ public void setPayoutState(PayoutState payoutState) {
19201919
}
19211920

19221921
this.payoutState = payoutState;
1923-
requestPersistence();
1922+
persistNow(null);
19241923
UserThread.execute(() -> payoutStateProperty.set(payoutState));
19251924
}
19261925

@@ -1936,6 +1935,7 @@ public void setDisputeState(DisputeState disputeState) {
19361935
}
19371936

19381937
this.disputeState = disputeState;
1938+
persistNow(null);
19391939
UserThread.execute(() -> {
19401940
disputeStateProperty.set(disputeState);
19411941
});

0 commit comments

Comments
 (0)