mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-25 15:29:23 -05:00
resend deposits confirmed messages until delivered
This commit is contained in:
parent
cd7f176e2b
commit
435fc164b2
@ -172,6 +172,9 @@ public class ProcessModel implements Model, PersistablePayload {
|
|||||||
@Setter
|
@Setter
|
||||||
private String multisigAddress;
|
private String multisigAddress;
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean isDepositsConfirmedMessagesDelivered;
|
||||||
|
|
||||||
// We want to indicate the user the state of the message delivery of the
|
// We want to indicate the user the state of the message delivery of the
|
||||||
// PaymentSentMessage. As well we do an automatic re-send in case it was not ACKed yet.
|
// PaymentSentMessage. As well we do an automatic re-send in case it was not ACKed yet.
|
||||||
|
@ -72,6 +72,7 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.fxmisc.easybind.EasyBind;
|
import org.fxmisc.easybind.EasyBind;
|
||||||
@ -244,13 +245,6 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||||||
processModel.getP2PService().addDecryptedDirectMessageListener(this);
|
processModel.getP2PService().addDecryptedDirectMessageListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle trade events
|
|
||||||
EasyBind.subscribe(trade.stateProperty(), state -> {
|
|
||||||
if (state == Trade.State.DEPOSIT_TXS_CONFIRMED_IN_BLOCKCHAIN) {
|
|
||||||
new Thread(() -> sendDepositsConfirmedMessage()).start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// initialize trade
|
// initialize trade
|
||||||
trade.initialize(processModel.getProvider());
|
trade.initialize(processModel.getProvider());
|
||||||
|
|
||||||
@ -258,6 +252,17 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||||||
MailboxMessageService mailboxMessageService = processModel.getP2PService().getMailboxMessageService();
|
MailboxMessageService mailboxMessageService = processModel.getP2PService().getMailboxMessageService();
|
||||||
mailboxMessageService.addDecryptedMailboxListener(this);
|
mailboxMessageService.addDecryptedMailboxListener(this);
|
||||||
handleMailboxCollection(mailboxMessageService.getMyDecryptedMailboxMessages());
|
handleMailboxCollection(mailboxMessageService.getMyDecryptedMailboxMessages());
|
||||||
|
|
||||||
|
// send deposit confirmed message on startup or event
|
||||||
|
if (trade.getState().ordinal() >= Trade.State.DEPOSIT_TXS_CONFIRMED_IN_BLOCKCHAIN.ordinal()) {
|
||||||
|
new Thread(() -> sendDepositsConfirmedMessages()).start();
|
||||||
|
} else {
|
||||||
|
EasyBind.subscribe(trade.stateProperty(), state -> {
|
||||||
|
if (state == Trade.State.DEPOSIT_TXS_CONFIRMED_IN_BLOCKCHAIN) {
|
||||||
|
new Thread(() -> sendDepositsConfirmedMessages()).start();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleInitMultisigRequest(InitMultisigRequest request, NodeAddress sender) {
|
public void handleInitMultisigRequest(InitMultisigRequest request, NodeAddress sender) {
|
||||||
@ -770,16 +775,24 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendDepositsConfirmedMessage() {
|
private void sendDepositsConfirmedMessages() {
|
||||||
synchronized (trade) {
|
synchronized (trade) {
|
||||||
|
if (!trade.isInitialized()) return; // skip if shutting down
|
||||||
|
if (trade.getProcessModel().isDepositsConfirmedMessagesDelivered()) return; // skip if already delivered
|
||||||
latchTrade();
|
latchTrade();
|
||||||
expect(new Condition(trade))
|
expect(new Condition(trade))
|
||||||
.setup(tasks(getDepositsConfirmedTasks())
|
.setup(tasks(getDepositsConfirmedTasks())
|
||||||
.using(new TradeTaskRunner(trade,
|
.using(new TradeTaskRunner(trade,
|
||||||
() -> {
|
() -> {
|
||||||
|
trade.getProcessModel().setDepositsConfirmedMessagesDelivered(true);
|
||||||
handleTaskRunnerSuccess(null, null, "SendDepositsConfirmedMessages");
|
handleTaskRunnerSuccess(null, null, "SendDepositsConfirmedMessages");
|
||||||
},
|
},
|
||||||
(errorMessage) -> {
|
(errorMessage) -> {
|
||||||
|
|
||||||
|
// retry in 15 minutes
|
||||||
|
UserThread.runAfter(() -> {
|
||||||
|
sendDepositsConfirmedMessages();
|
||||||
|
}, 15, TimeUnit.MINUTES);
|
||||||
handleTaskRunnerFault(null, null, "SendDepositsConfirmedMessages", errorMessage);
|
handleTaskRunnerFault(null, null, "SendDepositsConfirmedMessages", errorMessage);
|
||||||
})))
|
})))
|
||||||
.executeTasks(true);
|
.executeTasks(true);
|
||||||
|
@ -1708,6 +1708,7 @@ message ProcessModel {
|
|||||||
bytes mediated_payout_tx_signature = 18;
|
bytes mediated_payout_tx_signature = 18;
|
||||||
int64 buyer_payout_amount_from_mediation = 19;
|
int64 buyer_payout_amount_from_mediation = 19;
|
||||||
int64 seller_payout_amount_from_mediation = 20;
|
int64 seller_payout_amount_from_mediation = 20;
|
||||||
|
bool deposits_confirmed_messages_delivered = 21;
|
||||||
|
|
||||||
string maker_signature = 1001;
|
string maker_signature = 1001;
|
||||||
TradingPeer maker = 1002;
|
TradingPeer maker = 1002;
|
||||||
|
Loading…
Reference in New Issue
Block a user