From c7b8571842c91c502a8d09884ad59cd9b7d60223 Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 18 Dec 2023 11:05:34 -0500 Subject: [PATCH] reset timeout timer on progress creating offer --- .../java/haveno/core/offer/placeoffer/PlaceOfferModel.java | 3 +++ .../haveno/core/offer/placeoffer/PlaceOfferProtocol.java | 3 ++- .../core/offer/placeoffer/tasks/MakerReserveOfferFunds.java | 3 +++ .../offer/placeoffer/tasks/MakerSendSignOfferRequest.java | 5 +++++ .../core/trade/protocol/tasks/TakerReserveTradeFunds.java | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferModel.java b/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferModel.java index 30c4b2233c..499c3fd112 100644 --- a/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferModel.java +++ b/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferModel.java @@ -71,6 +71,9 @@ public class PlaceOfferModel implements Model { private MoneroTxWallet reserveTx; @Setter private SignOfferResponse signOfferResponse; + @Setter + @Getter + protected PlaceOfferProtocol protocol; public PlaceOfferModel(OpenOffer openOffer, BigInteger reservedFundsForOffer, diff --git a/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferProtocol.java b/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferProtocol.java index e5d1120f1e..ab8d1fa0cd 100644 --- a/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferProtocol.java +++ b/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferProtocol.java @@ -51,6 +51,7 @@ public class PlaceOfferProtocol { TransactionResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { this.model = model; + this.model.setProtocol(this); this.resultHandler = resultHandler; this.errorMessageHandler = errorMessageHandler; } @@ -128,7 +129,7 @@ public class PlaceOfferProtocol { taskRunner.run(); } - private void startTimeoutTimer() { + public void startTimeoutTimer() { stopTimeoutTimer(); timeoutTimer = UserThread.runAfter(() -> { handleError(Res.get("createOffer.timeoutAtPublishing")); diff --git a/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java b/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java index 73bc8f9cb1..8628b72e40 100644 --- a/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java +++ b/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java @@ -64,6 +64,9 @@ public class MakerReserveOfferFunds extends Task { throw new RuntimeException("An error has occurred posting offer " + offer.getId() + " causing its subaddress entry to be deleted"); } + // reset protocol timeout + model.getProtocol().startTimeoutTimer(); + // collect reserved key images List reservedKeyImages = new ArrayList(); for (MoneroOutput input : reserveTx.getInputs()) reservedKeyImages.add(input.getKeyImage().getHex()); diff --git a/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerSendSignOfferRequest.java b/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerSendSignOfferRequest.java index 5ac62d453a..fd9b65dbb2 100644 --- a/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerSendSignOfferRequest.java +++ b/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerSendSignOfferRequest.java @@ -135,12 +135,17 @@ public class MakerSendSignOfferRequest extends Task { public void onFault(String errorMessage) { log.warn("Arbitrator unavailable: address={}: {}", arbitratorNodeAddress, errorMessage); excludedArbitrators.add(arbitratorNodeAddress); + + // get alternative arbitrator Arbitrator altArbitrator = DisputeAgentSelection.getRandomArbitrator(model.getArbitratorManager(), excludedArbitrators); if (altArbitrator == null) { errorMessageHandler.handleErrorMessage("Offer " + request.getOfferId() + " could not be signed by any arbitrator"); return; } + + // send request to alrernative arbitrator log.info("Using alternative arbitrator {}", altArbitrator.getNodeAddress()); + model.getProtocol().startTimeoutTimer(); // reset timeout sendSignOfferRequests(request, altArbitrator.getNodeAddress(), excludedArbitrators, resultHandler, errorMessageHandler); } }); diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/TakerReserveTradeFunds.java b/core/src/main/java/haveno/core/trade/protocol/tasks/TakerReserveTradeFunds.java index a79cc046ed..51d7960bd7 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/TakerReserveTradeFunds.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/TakerReserveTradeFunds.java @@ -57,7 +57,7 @@ public class TakerReserveTradeFunds extends TradeTask { throw new RuntimeException("An error has occurred taking trade " + trade.getId() + " causing its subaddress entry to be deleted"); } - // extend protocol timeout + // reset protocol timeout trade.getProtocol().startTimeout(TradeProtocol.TRADE_TIMEOUT); // save process state