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