do not process payment confirmation messages if shut down started

This commit is contained in:
woodser 2025-03-16 18:18:48 -04:00 committed by woodser
parent 5711aabad8
commit 6f3ae49b68

View file

@ -291,10 +291,11 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
public void maybeReprocessPaymentSentMessage(boolean reprocessOnError) {
if (trade.isShutDownStarted()) return;
ThreadUtils.execute(() -> {
if (trade.isShutDownStarted()) return;
synchronized (trade.getLock()) {
// skip if no need to reprocess
if (trade.isBuyer() || trade.getBuyer().getPaymentSentMessage() == null || trade.getState().ordinal() >= Trade.State.BUYER_SENT_PAYMENT_SENT_MSG.ordinal()) {
if (trade.isShutDownStarted() || trade.isBuyer() || trade.getBuyer().getPaymentSentMessage() == null || trade.getState().ordinal() >= Trade.State.BUYER_SENT_PAYMENT_SENT_MSG.ordinal()) {
return;
}
@ -307,10 +308,11 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
public void maybeReprocessPaymentReceivedMessage(boolean reprocessOnError) {
if (trade.isShutDownStarted()) return;
ThreadUtils.execute(() -> {
if (trade.isShutDownStarted()) return;
synchronized (trade.getLock()) {
// skip if no need to reprocess
if (trade.isSeller() || trade.getSeller().getPaymentReceivedMessage() == null || (trade.getState().ordinal() >= Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG.ordinal() && trade.isPayoutPublished())) {
if (trade.isShutDownStarted() || trade.isSeller() || trade.getSeller().getPaymentReceivedMessage() == null || (trade.getState().ordinal() >= Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG.ordinal() && trade.isPayoutPublished())) {
return;
}
@ -525,7 +527,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
trade.getBuyer().setPaymentSentMessage(message);
trade.requestPersistence();
if (!trade.isInitialized() || trade.isShutDown()) return;
if (!trade.isInitialized() || trade.isShutDownStarted()) return;
if (!(trade instanceof SellerTrade || trade instanceof ArbitratorTrade)) {
log.warn("Ignoring PaymentSentMessage since not seller or arbitrator");
return;
@ -537,7 +539,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
// TODO A better fix would be to add a listener for the wallet sync state and process
// the mailbox msg once wallet is ready and trade state set.
synchronized (trade.getLock()) {
if (!trade.isInitialized() || trade.isShutDown()) return;
if (!trade.isInitialized() || trade.isShutDownStarted()) return;
if (trade.getPhase().ordinal() >= Trade.Phase.PAYMENT_SENT.ordinal()) {
log.warn("Received another PaymentSentMessage which was already processed for {} {}, ACKing", trade.getClass().getSimpleName(), trade.getId());
handleTaskRunnerSuccess(peer, message);
@ -604,14 +606,14 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
trade.getSeller().setPaymentReceivedMessage(message);
trade.requestPersistence();
if (!trade.isInitialized() || trade.isShutDown()) return;
if (!trade.isInitialized() || trade.isShutDownStarted()) return;
ThreadUtils.execute(() -> {
if (!(trade instanceof BuyerTrade || trade instanceof ArbitratorTrade)) {
log.warn("Ignoring PaymentReceivedMessage since not buyer or arbitrator");
return;
}
synchronized (trade.getLock()) {
if (!trade.isInitialized() || trade.isShutDown()) return;
if (!trade.isInitialized() || trade.isShutDownStarted()) return;
latchTrade();
Validator.checkTradeId(processModel.getOfferId(), message);
processModel.setTradeMessage(message);