mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
re-send payment sent/received messages on startup if not arrived
This commit is contained in:
parent
e20e23dbc5
commit
7ca3b8cee1
@ -53,16 +53,28 @@ public class BuyerProtocol extends DisputeProtocol {
|
||||
protected void onInitialized() {
|
||||
super.onInitialized();
|
||||
|
||||
// TODO: run with trade lock and latch, otherwise getting invalid transition warnings on startup after offline trades
|
||||
|
||||
// send payment sent message
|
||||
// re-send payment sent message if not arrived
|
||||
if (trade.getState() == Trade.State.BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG || trade.getState() == Trade.State.BUYER_SEND_FAILED_PAYMENT_SENT_MSG) {
|
||||
synchronized (trade) {
|
||||
latchTrade();
|
||||
given(anyPhase(Trade.Phase.PAYMENT_SENT)
|
||||
.anyState(Trade.State.BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG, Trade.State.BUYER_SEND_FAILED_PAYMENT_SENT_MSG)
|
||||
.with(BuyerEvent.STARTUP))
|
||||
.setup(tasks(
|
||||
BuyerSendPaymentSentMessageToSeller.class,
|
||||
BuyerSendPaymentSentMessageToArbitrator.class))
|
||||
BuyerSendPaymentSentMessageToArbitrator.class)
|
||||
.using(new TradeTaskRunner(trade,
|
||||
() -> {
|
||||
unlatchTrade();
|
||||
},
|
||||
(errorMessage) -> {
|
||||
log.warn("Error sending PaymentSentMessage on startup: " + errorMessage);
|
||||
unlatchTrade();
|
||||
})))
|
||||
.executeTasks();
|
||||
awaitTradeLatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
package bisq.core.trade.protocol;
|
||||
|
||||
import bisq.common.handlers.ErrorMessageHandler;
|
||||
import bisq.common.handlers.ResultHandler;
|
||||
import bisq.core.trade.SellerTrade;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.messages.SignContractResponse;
|
||||
@ -24,13 +26,11 @@ import bisq.core.trade.messages.TradeMessage;
|
||||
import bisq.core.trade.protocol.tasks.ApplyFilter;
|
||||
import bisq.core.trade.protocol.tasks.SellerPreparePaymentReceivedMessage;
|
||||
import bisq.core.trade.protocol.tasks.SellerSendPaymentReceivedMessageToArbitrator;
|
||||
import bisq.core.trade.protocol.tasks.SendDepositsConfirmedMessageToBuyer;
|
||||
import bisq.core.trade.protocol.tasks.SellerSendPaymentReceivedMessageToBuyer;
|
||||
import bisq.core.trade.protocol.tasks.SendDepositsConfirmedMessageToArbitrator;
|
||||
import bisq.core.trade.protocol.tasks.SendDepositsConfirmedMessageToBuyer;
|
||||
import bisq.core.trade.protocol.tasks.TradeTask;
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
import bisq.common.handlers.ErrorMessageHandler;
|
||||
import bisq.common.handlers.ResultHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@ -48,6 +48,29 @@ public class SellerProtocol extends DisputeProtocol {
|
||||
@Override
|
||||
protected void onInitialized() {
|
||||
super.onInitialized();
|
||||
|
||||
// re-send payment received message if not arrived
|
||||
if (trade.getState() == Trade.State.SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG || trade.getState() == Trade.State.SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG) {
|
||||
synchronized (trade) {
|
||||
latchTrade();
|
||||
given(anyPhase(Trade.Phase.PAYMENT_RECEIVED)
|
||||
.anyState(Trade.State.SELLER_STORED_IN_MAILBOX_PAYMENT_RECEIVED_MSG, Trade.State.SELLER_SEND_FAILED_PAYMENT_RECEIVED_MSG)
|
||||
.with(SellerEvent.STARTUP))
|
||||
.setup(tasks(
|
||||
SellerSendPaymentReceivedMessageToBuyer.class,
|
||||
SellerSendPaymentReceivedMessageToArbitrator.class)
|
||||
.using(new TradeTaskRunner(trade,
|
||||
() -> {
|
||||
unlatchTrade();
|
||||
},
|
||||
(errorMessage) -> {
|
||||
log.warn("Error sending PaymentReceivedMessage on startup: " + errorMessage);
|
||||
unlatchTrade();
|
||||
})))
|
||||
.executeTasks();
|
||||
awaitTradeLatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user