mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 11:39:29 +00:00
check if dispute payout published on submit failure, thread fixes
This commit is contained in:
parent
a3f2cd875c
commit
467b678ea7
3 changed files with 14 additions and 10 deletions
|
@ -758,6 +758,7 @@ public abstract class DisputeManager<T extends DisputeList<Dispute>> extends Sup
|
|||
// create dispute closed message
|
||||
TradePeer receiverPeer = receiver == trade.getBuyer() ? trade.getSeller() : trade.getBuyer();
|
||||
boolean deferPublishPayout = !exists && receiver.getUnsignedPayoutTxHex() != null && receiverPeer.getUpdatedMultisigHex() != null && trade.getDisputeState().ordinal() >= Trade.DisputeState.ARBITRATOR_SAW_ARRIVED_DISPUTE_CLOSED_MSG.ordinal();
|
||||
log.info("deferPublishPayout = {} = {} && {} && {} && {}", deferPublishPayout, !exists, receiver.getUnsignedPayoutTxHex() != null, receiverPeer.getUpdatedMultisigHex() != null, trade.getDisputeState().ordinal() >= Trade.DisputeState.ARBITRATOR_SAW_ARRIVED_DISPUTE_CLOSED_MSG.ordinal());
|
||||
DisputeClosedMessage disputeClosedMessage = new DisputeClosedMessage(disputeResult,
|
||||
p2PService.getAddress(),
|
||||
UUID.randomUUID().toString(),
|
||||
|
@ -856,7 +857,7 @@ public abstract class DisputeManager<T extends DisputeList<Dispute>> extends Sup
|
|||
if (!trade.isPayoutPublished()) {
|
||||
|
||||
// create unsigned dispute payout tx
|
||||
log.info("Creating unsigned dispute payout tx for trade {}", trade.getId());
|
||||
if (updateState) log.info("Creating unsigned dispute payout tx for trade {}", trade.getId());
|
||||
try {
|
||||
|
||||
// trade wallet must be synced
|
||||
|
|
|
@ -477,6 +477,7 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
|
|||
disputeTxSet.getTxs().get(0).setHash(txHashes.get(0)); // manually update hash which is known after signed
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
if (trade.isPayoutPublished()) throw new IllegalStateException("Payout tx already published for " + trade.getClass().getSimpleName() + " " + trade.getShortId());
|
||||
log.warn("Failed to submit dispute payout tx, attempt={}/{}, tradeId={}, error={}", i + 1, TradeProtocol.MAX_ATTEMPTS, trade.getShortId(), e.getMessage());
|
||||
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
||||
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
||||
|
|
|
@ -641,7 +641,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
// handle trade phase events
|
||||
tradePhaseSubscription = EasyBind.subscribe(phaseProperty, newValue -> {
|
||||
if (!isInitialized || isShutDownStarted) return;
|
||||
ThreadUtils.execute(() -> {
|
||||
ThreadUtils.submitToPool(() -> {
|
||||
if (newValue == Trade.Phase.DEPOSIT_REQUESTED) startPolling();
|
||||
if (isDepositsPublished() && !isPayoutUnlocked()) updatePollPeriod();
|
||||
if (isPaymentReceived()) {
|
||||
|
@ -652,13 +652,13 @@ public abstract class Trade implements Tradable, Model {
|
|||
}
|
||||
});
|
||||
}
|
||||
}, getId());
|
||||
});
|
||||
});
|
||||
|
||||
// handle payout events
|
||||
payoutStateSubscription = EasyBind.subscribe(payoutStateProperty, newValue -> {
|
||||
if (!isInitialized || isShutDownStarted) return;
|
||||
ThreadUtils.execute(() -> {
|
||||
ThreadUtils.submitToPool(() -> {
|
||||
if (isPayoutPublished()) updatePollPeriod();
|
||||
|
||||
// handle when payout published
|
||||
|
@ -666,11 +666,13 @@ public abstract class Trade implements Tradable, Model {
|
|||
log.info("Payout published for {} {}", getClass().getSimpleName(), getId());
|
||||
|
||||
// sync main wallet to update pending balance
|
||||
new Thread(() -> {
|
||||
HavenoUtils.waitFor(1000);
|
||||
if (isShutDownStarted) return;
|
||||
if (xmrConnectionService.isConnected()) xmrWalletService.syncWallet();
|
||||
}).start();
|
||||
if (!isPayoutConfirmed()) {
|
||||
new Thread(() -> {
|
||||
HavenoUtils.waitFor(1000);
|
||||
if (isShutDownStarted) return;
|
||||
if (xmrConnectionService.isConnected()) syncAndPollWallet();
|
||||
}).start();
|
||||
}
|
||||
|
||||
// complete disputed trade
|
||||
if (getDisputeState().isArbitrated() && !getDisputeState().isClosed()) {
|
||||
|
@ -691,7 +693,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
log.info("Payout unlocked for {} {}, deleting multisig wallet", getClass().getSimpleName(), getId());
|
||||
clearAndShutDown();
|
||||
}
|
||||
}, getId());
|
||||
});
|
||||
});
|
||||
|
||||
// arbitrator syncs idle wallet when payout unlock expected
|
||||
|
|
Loading…
Reference in a new issue