mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-25 23:39:26 -05:00
process trade state notifications off UserThread
This commit is contained in:
parent
43bbb29384
commit
e7371d1299
@ -263,8 +263,11 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
|
||||
// wait to sign and publish payout tx if defer flag set
|
||||
if (disputeClosedMessage.isDeferPublishPayout()) {
|
||||
log.info("Deferring signing and publishing dispute payout tx for {} {}", trade.getClass().getSimpleName(), trade.getId());
|
||||
GenUtils.waitFor(Trade.DEFER_PUBLISH_MS);
|
||||
if (!trade.isPayoutUnlocked()) trade.syncAndPollWallet();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (trade.isPayoutPublished()) break;
|
||||
GenUtils.waitFor(Trade.DEFER_PUBLISH_MS / 5);
|
||||
}
|
||||
if (!trade.isPayoutPublished()) trade.syncAndPollWallet();
|
||||
}
|
||||
|
||||
// sign and publish dispute payout tx if peer still has not published
|
||||
|
@ -621,14 +621,17 @@ public abstract class Trade implements Tradable, Model {
|
||||
|
||||
// handle trade state events
|
||||
tradeStateSubscription = EasyBind.subscribe(stateProperty, newValue -> {
|
||||
HavenoUtils.submitToThread(() -> {
|
||||
if (newValue == Trade.State.MULTISIG_COMPLETED) {
|
||||
updateWalletRefreshPeriod();
|
||||
startPolling();
|
||||
}
|
||||
}, getId());
|
||||
});
|
||||
|
||||
// handle trade phase events
|
||||
tradePhaseSubscription = EasyBind.subscribe(phaseProperty, newValue -> {
|
||||
HavenoUtils.submitToThread(() -> {
|
||||
if (isDepositsPublished() && !isPayoutUnlocked()) updateWalletRefreshPeriod();
|
||||
if (isPaymentReceived()) {
|
||||
UserThread.execute(() -> {
|
||||
@ -638,10 +641,12 @@ public abstract class Trade implements Tradable, Model {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, getId());
|
||||
});
|
||||
|
||||
// handle payout events
|
||||
payoutStateSubscription = EasyBind.subscribe(payoutStateProperty, newValue -> {
|
||||
HavenoUtils.submitToThread(() -> {
|
||||
if (isPayoutPublished()) updateWalletRefreshPeriod();
|
||||
|
||||
// handle when payout published
|
||||
@ -672,6 +677,7 @@ public abstract class Trade implements Tradable, Model {
|
||||
if (newValue == Trade.PayoutState.PAYOUT_UNLOCKED) {
|
||||
if (!isInitialized) return;
|
||||
log.info("Payout unlocked for {} {}, deleting multisig wallet", getClass().getSimpleName(), getId());
|
||||
HavenoUtils.submitToThread(() -> {
|
||||
deleteWallet();
|
||||
maybeClearProcessData();
|
||||
if (idlePayoutSyncer != null) {
|
||||
@ -684,7 +690,10 @@ public abstract class Trade implements Tradable, Model {
|
||||
payoutStateSubscription = null;
|
||||
}
|
||||
});
|
||||
}, getId());
|
||||
|
||||
}
|
||||
}, getId());
|
||||
});
|
||||
|
||||
// arbitrator syncs idle wallet when payout unlock expected
|
||||
|
@ -128,8 +128,11 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
|
||||
boolean deferSignAndPublish = trade instanceof ArbitratorTrade && !isSigned && message.isDeferPublishPayout();
|
||||
if (deferSignAndPublish) {
|
||||
log.info("Deferring signing and publishing payout tx for {} {}", trade.getClass().getSimpleName(), trade.getId());
|
||||
GenUtils.waitFor(Trade.DEFER_PUBLISH_MS);
|
||||
if (!trade.isPayoutUnlocked()) trade.syncAndPollWallet();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (trade.isPayoutPublished()) break;
|
||||
GenUtils.waitFor(Trade.DEFER_PUBLISH_MS / 5);
|
||||
}
|
||||
if (!trade.isPayoutPublished()) trade.syncAndPollWallet();
|
||||
}
|
||||
|
||||
// verify and publish payout tx
|
||||
|
Loading…
Reference in New Issue
Block a user