resend payment sent & received messages from trade thread on startup

This commit is contained in:
woodser 2024-02-01 07:43:31 -05:00
parent bbec107dcc
commit 6f51d333ec
2 changed files with 46 additions and 40 deletions

View File

@ -55,8 +55,10 @@ public class BuyerProtocol extends DisputeProtocol {
super.onInitialized();
// re-send payment sent message if not acked
ThreadUtils.execute(() -> {
if (trade.isShutDownStarted() || trade.isPayoutPublished()) return;
synchronized (trade) {
if (trade.isShutDownStarted()) return;
if (trade.isShutDownStarted() || trade.isPayoutPublished()) return;
if (trade.getState().ordinal() >= Trade.State.BUYER_SENT_PAYMENT_SENT_MSG.ordinal() && trade.getState().ordinal() < Trade.State.SELLER_RECEIVED_PAYMENT_SENT_MSG.ordinal()) {
latchTrade();
given(anyPhase(Trade.Phase.PAYMENT_SENT)
@ -76,6 +78,7 @@ public class BuyerProtocol extends DisputeProtocol {
awaitTradeLatch();
}
}
}, trade.getId());
}
@Override

View File

@ -51,8 +51,10 @@ public class SellerProtocol extends DisputeProtocol {
super.onInitialized();
// re-send payment received message if payout not published
ThreadUtils.execute(() -> {
if (trade.isShutDownStarted() || trade.isPayoutPublished()) return;
synchronized (trade) {
if (trade.isShutDownStarted()) return;
if (trade.isShutDownStarted() || trade.isPayoutPublished()) return;
if (trade.getState().ordinal() >= Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG.ordinal() && !trade.isPayoutPublished()) {
latchTrade();
given(anyPhase(Trade.Phase.PAYMENT_RECEIVED)
@ -72,6 +74,7 @@ public class SellerProtocol extends DisputeProtocol {
awaitTradeLatch();
}
}
}, trade.getId());
}
@Override