mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-12-16 08:14:15 -05:00
use functions to determine if payment sent/received messages processed
This commit is contained in:
parent
e47c9774d8
commit
bc71c3e201
4 changed files with 16 additions and 5 deletions
|
|
@ -2775,6 +2775,12 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
|||
return getState().getPhase().ordinal() >= Phase.PAYMENT_SENT.ordinal() && getState() != State.BUYER_SEND_FAILED_PAYMENT_SENT_MSG;
|
||||
}
|
||||
|
||||
public boolean isPaymentSentMessageProcessed() {
|
||||
if (isPaymentReceived()) return true;
|
||||
if (isBuyer()) return getState() == State.SELLER_RECEIVED_PAYMENT_SENT_MSG;
|
||||
return getState() == Trade.State.BUYER_SENT_PAYMENT_SENT_MSG;
|
||||
}
|
||||
|
||||
public boolean isPaymentMarkedReceived() {
|
||||
return getState().getPhase().ordinal() >= Phase.PAYMENT_RECEIVED.ordinal();
|
||||
}
|
||||
|
|
@ -2783,6 +2789,11 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
|||
return getState().getPhase().ordinal() >= Phase.PAYMENT_RECEIVED.ordinal() && getState() != State.SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG;
|
||||
}
|
||||
|
||||
public boolean isPaymentReceivedMessageProcessed() {
|
||||
if (isSeller()) return getState() == State.BUYER_RECEIVED_PAYMENT_RECEIVED_MSG;
|
||||
return getState() == Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG;
|
||||
}
|
||||
|
||||
public boolean isPayoutPublished() {
|
||||
return getPayoutState().ordinal() >= PayoutState.PAYOUT_PUBLISHED.ordinal();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public class SellerProtocol extends DisputeProtocol {
|
|||
log.info(TradeProtocol.LOG_HIGHLIGHT + "SellerProtocol.onPaymentReceived() for {} {}", trade.getClass().getSimpleName(), trade.getShortId());
|
||||
|
||||
// advance trade state
|
||||
if (trade.getState() == Trade.State.BUYER_SENT_PAYMENT_SENT_MSG || trade.isPaymentReceived()) {
|
||||
if (trade.isPaymentSentMessageProcessed()) {
|
||||
trade.setStateIfValidTransitionTo(Trade.State.SELLER_CONFIRMED_PAYMENT_RECEIPT);
|
||||
} else {
|
||||
errorMessageHandler.handleErrorMessage("Cannot confirm payment received for " + trade.getClass().getSimpleName() + " " + trade.getShortId() + " in state " + trade.getState());
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
// the mailbox msg once wallet is ready and trade state set.
|
||||
synchronized (trade.getLock()) {
|
||||
if (!trade.isInitialized() || trade.isShutDownStarted()) return;
|
||||
if (trade.getState().ordinal() >= Trade.State.BUYER_SENT_PAYMENT_SENT_MSG.ordinal()) {
|
||||
if (trade.isPaymentSentMessageProcessed()) {
|
||||
log.warn("Received another PaymentSentMessage which was already processed for {} {}, ACKing", trade.getClass().getSimpleName(), trade.getId());
|
||||
handleTaskRunnerSuccess(trade.getBuyer().getNodeAddress(), message);
|
||||
return;
|
||||
|
|
@ -720,8 +720,8 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||
log.warn("Skipping processing PaymentReceivedMessage because the trade is not initialized or it's shutting down for {} {}", trade.getClass().getSimpleName(), trade.getId());
|
||||
return;
|
||||
}
|
||||
if (trade.getState().ordinal() >= Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG.ordinal() && trade.isPayoutPublished()) {
|
||||
log.warn("Received another PaymentReceivedMessage after payout is published for {} {}, ACKing", trade.getClass().getSimpleName(), trade.getId());
|
||||
if (trade.isPaymentReceivedMessageProcessed() && trade.isPayoutPublished()) {
|
||||
log.warn("Received another PaymentReceivedMessage after processed and payout is published for {} {}, ACKing", trade.getClass().getSimpleName(), trade.getId());
|
||||
handleTaskRunnerSuccess(trade.getSeller().getNodeAddress(), message);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
|
|||
trade.requestPersistence();
|
||||
|
||||
// ack and complete if already processed
|
||||
if (trade.getState().ordinal() >= Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG.ordinal() && trade.isPayoutPublished()) {
|
||||
if (trade.isPaymentReceivedMessageProcessed() && trade.isPayoutPublished()) {
|
||||
log.warn("Received another PaymentReceivedMessage which was already processed, ACKing");
|
||||
complete();
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue