reprocess trade messages off UserThread
This commit is contained in:
parent
9a6a9ac93e
commit
0a3736bba0
@ -325,6 +325,7 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
|
||||
}
|
||||
|
||||
public void maybeReprocessDisputeClosedMessage(Trade trade, boolean reprocessOnError) {
|
||||
new Thread(() -> {
|
||||
synchronized (trade) {
|
||||
|
||||
// skip if no need to reprocess
|
||||
@ -333,8 +334,9 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
|
||||
}
|
||||
|
||||
log.warn("Reprocessing dispute closed message for {} {}", trade.getClass().getSimpleName(), trade.getId());
|
||||
new Thread(() -> handleDisputeClosedMessage(trade.getArbitrator().getDisputeClosedMessage(), reprocessOnError)).start();
|
||||
handleDisputeClosedMessage(trade.getArbitrator().getDisputeClosedMessage(), reprocessOnError);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private MoneroTxSet signAndPublishDisputePayoutTx(Trade trade) {
|
||||
|
@ -259,17 +259,33 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
||||
}
|
||||
|
||||
// send deposits confirmed message if applicable
|
||||
maybeSendDepositsConfirmedMessage();
|
||||
maybeSendDepositsConfirmedMessages();
|
||||
EasyBind.subscribe(trade.stateProperty(), state -> maybeSendDepositsConfirmedMessages());
|
||||
}
|
||||
|
||||
private void maybeSendDepositsConfirmedMessage() {
|
||||
HavenoUtils.submitToThread(() -> maybeSendDepositsConfirmedMessages(), trade.getId());
|
||||
EasyBind.subscribe(trade.stateProperty(), state -> {
|
||||
HavenoUtils.submitToThread(() -> maybeSendDepositsConfirmedMessages(), trade.getId());
|
||||
});
|
||||
public void maybeSendDepositsConfirmedMessages() {
|
||||
HavenoUtils.submitToThread(() -> {
|
||||
if (!trade.isDepositsConfirmed() || trade.isDepositsConfirmedAcked() || trade.isPayoutPublished()) return;
|
||||
synchronized (trade) {
|
||||
if (!trade.isInitialized() || trade.isShutDownStarted()) return; // skip if shutting down
|
||||
latchTrade();
|
||||
expect(new Condition(trade))
|
||||
.setup(tasks(getDepositsConfirmedTasks())
|
||||
.using(new TradeTaskRunner(trade,
|
||||
() -> {
|
||||
handleTaskRunnerSuccess(null, null, "maybeSendDepositsConfirmedMessages");
|
||||
},
|
||||
(errorMessage) -> {
|
||||
handleTaskRunnerFault(null, null, "maybeSendDepositsConfirmedMessages", errorMessage);
|
||||
})))
|
||||
.executeTasks(true);
|
||||
awaitTradeLatch();
|
||||
}
|
||||
}, trade.getId());
|
||||
}
|
||||
|
||||
public void maybeReprocessPaymentReceivedMessage(boolean reprocessOnError) {
|
||||
HavenoUtils.submitToThread(() -> {
|
||||
synchronized (trade) {
|
||||
|
||||
// skip if no need to reprocess
|
||||
@ -278,11 +294,12 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
||||
}
|
||||
|
||||
log.warn("Reprocessing payment received message for {} {}", trade.getClass().getSimpleName(), trade.getId());
|
||||
HavenoUtils.submitToThread(() -> {
|
||||
handle(trade.getSeller().getPaymentReceivedMessage(), trade.getSeller().getPaymentReceivedMessage().getSenderNodeAddress(), reprocessOnError);
|
||||
}
|
||||
|
||||
handle(trade.getSeller().getPaymentReceivedMessage(), trade.getSeller().getPaymentReceivedMessage().getSenderNodeAddress(), reprocessOnError);
|
||||
}, trade.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void handleInitMultisigRequest(InitMultisigRequest request, NodeAddress sender) {
|
||||
System.out.println(getClass().getSimpleName() + ".handleInitMultisigRequest()");
|
||||
@ -844,23 +861,4 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void maybeSendDepositsConfirmedMessages() {
|
||||
if (!trade.isDepositsConfirmed() || trade.isDepositsConfirmedAcked() || trade.isPayoutPublished()) return;
|
||||
synchronized (trade) {
|
||||
if (!trade.isInitialized() || trade.isShutDownStarted()) return; // skip if shutting down
|
||||
latchTrade();
|
||||
expect(new Condition(trade))
|
||||
.setup(tasks(getDepositsConfirmedTasks())
|
||||
.using(new TradeTaskRunner(trade,
|
||||
() -> {
|
||||
handleTaskRunnerSuccess(null, null, "maybeSendDepositsConfirmedMessages");
|
||||
},
|
||||
(errorMessage) -> {
|
||||
handleTaskRunnerFault(null, null, "maybeSendDepositsConfirmedMessages", errorMessage);
|
||||
})))
|
||||
.executeTasks(true);
|
||||
awaitTradeLatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user