From 3d0b8c0b09f6d5ec68d59747839fe014ae582392 Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 20 Nov 2023 15:41:05 -0500 Subject: [PATCH] process mailbox messages on main thread on startup --- .../core/trade/protocol/TradeProtocol.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java index 6289305056..448eda5e33 100644 --- a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java @@ -109,7 +109,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D protected void onTradeMessage(TradeMessage message, NodeAddress peerNodeAddress) { log.info("Received {} as TradeMessage from {} with tradeId {} and uid {}", message.getClass().getSimpleName(), peerNodeAddress, message.getTradeId(), message.getUid()); - handle(message, peerNodeAddress); + new Thread(() -> handle(message, peerNodeAddress)).start(); } protected void onMailboxMessage(TradeMessage message, NodeAddress peerNodeAddress) { @@ -118,15 +118,13 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D } private void handle(TradeMessage message, NodeAddress peerNodeAddress) { - new Thread(() -> { - if (message instanceof DepositsConfirmedMessage) { - handle((DepositsConfirmedMessage) message, peerNodeAddress); - } else if (message instanceof PaymentSentMessage) { - handle((PaymentSentMessage) message, peerNodeAddress); - } else if (message instanceof PaymentReceivedMessage) { - handle((PaymentReceivedMessage) message, peerNodeAddress); - } - }).start(); + if (message instanceof DepositsConfirmedMessage) { + handle((DepositsConfirmedMessage) message, peerNodeAddress); + } else if (message instanceof PaymentSentMessage) { + handle((PaymentSentMessage) message, peerNodeAddress); + } else if (message instanceof PaymentReceivedMessage) { + handle((PaymentReceivedMessage) message, peerNodeAddress); + } } @Override @@ -523,7 +521,6 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D Validator.checkTradeId(processModel.getOfferId(), message); processModel.setTradeMessage(message); - // check minimum trade phase if (trade.isBuyer() && trade.getPhase().ordinal() < Trade.Phase.PAYMENT_SENT.ordinal()) { log.warn("Received PaymentReceivedMessage before payment sent for {} {}, ignoring", trade.getClass().getSimpleName(), trade.getId());