process payment confirmation messages off main thread

This commit is contained in:
woodser 2022-08-31 16:31:09 -04:00
parent dbc7ff265a
commit b95c689190
2 changed files with 58 additions and 54 deletions

View file

@ -127,6 +127,7 @@ public abstract class BuyerProtocol extends DisputeProtocol {
protected void handle(PaymentReceivedMessage message, NodeAddress peer) {
log.info("BuyerProtocol.handle(PaymentReceivedMessage)");
new Thread(() -> {
synchronized (trade) {
latchTrade();
Validator.checkTradeId(processModel.getOfferId(), message);
@ -146,6 +147,7 @@ public abstract class BuyerProtocol extends DisputeProtocol {
.executeTasks(true);
awaitTradeLatch();
}
}).start();
}

View file

@ -77,6 +77,7 @@ public abstract class SellerProtocol extends DisputeProtocol {
protected void handle(PaymentSentMessage message, NodeAddress peer) {
log.info("SellerProtocol.handle(PaymentSentMessage)");
new Thread(() -> {
// We are more tolerant with expected phase and allow also DEPOSITS_PUBLISHED as it can be the case
// that the wallet is still syncing and so the DEPOSITS_CONFIRMED state to yet triggered when we received
// a mailbox message with PaymentSentMessage.
@ -113,6 +114,7 @@ public abstract class SellerProtocol extends DisputeProtocol {
.executeTasks(true);
awaitTradeLatch();
}
}).start();
}
///////////////////////////////////////////////////////////////////////////////////////////