reset timeout timer on progress creating offer

This commit is contained in:
woodser 2023-12-18 11:05:34 -05:00
parent 1df2ab4389
commit c7b8571842
5 changed files with 14 additions and 2 deletions

View file

@ -71,6 +71,9 @@ public class PlaceOfferModel implements Model {
private MoneroTxWallet reserveTx; private MoneroTxWallet reserveTx;
@Setter @Setter
private SignOfferResponse signOfferResponse; private SignOfferResponse signOfferResponse;
@Setter
@Getter
protected PlaceOfferProtocol protocol;
public PlaceOfferModel(OpenOffer openOffer, public PlaceOfferModel(OpenOffer openOffer,
BigInteger reservedFundsForOffer, BigInteger reservedFundsForOffer,

View file

@ -51,6 +51,7 @@ public class PlaceOfferProtocol {
TransactionResultHandler resultHandler, TransactionResultHandler resultHandler,
ErrorMessageHandler errorMessageHandler) { ErrorMessageHandler errorMessageHandler) {
this.model = model; this.model = model;
this.model.setProtocol(this);
this.resultHandler = resultHandler; this.resultHandler = resultHandler;
this.errorMessageHandler = errorMessageHandler; this.errorMessageHandler = errorMessageHandler;
} }
@ -128,7 +129,7 @@ public class PlaceOfferProtocol {
taskRunner.run(); taskRunner.run();
} }
private void startTimeoutTimer() { public void startTimeoutTimer() {
stopTimeoutTimer(); stopTimeoutTimer();
timeoutTimer = UserThread.runAfter(() -> { timeoutTimer = UserThread.runAfter(() -> {
handleError(Res.get("createOffer.timeoutAtPublishing")); handleError(Res.get("createOffer.timeoutAtPublishing"));

View file

@ -64,6 +64,9 @@ public class MakerReserveOfferFunds extends Task<PlaceOfferModel> {
throw new RuntimeException("An error has occurred posting offer " + offer.getId() + " causing its subaddress entry to be deleted"); 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 // collect reserved key images
List<String> reservedKeyImages = new ArrayList<String>(); List<String> reservedKeyImages = new ArrayList<String>();
for (MoneroOutput input : reserveTx.getInputs()) reservedKeyImages.add(input.getKeyImage().getHex()); for (MoneroOutput input : reserveTx.getInputs()) reservedKeyImages.add(input.getKeyImage().getHex());

View file

@ -135,12 +135,17 @@ public class MakerSendSignOfferRequest extends Task<PlaceOfferModel> {
public void onFault(String errorMessage) { public void onFault(String errorMessage) {
log.warn("Arbitrator unavailable: address={}: {}", arbitratorNodeAddress, errorMessage); log.warn("Arbitrator unavailable: address={}: {}", arbitratorNodeAddress, errorMessage);
excludedArbitrators.add(arbitratorNodeAddress); excludedArbitrators.add(arbitratorNodeAddress);
// get alternative arbitrator
Arbitrator altArbitrator = DisputeAgentSelection.getRandomArbitrator(model.getArbitratorManager(), excludedArbitrators); Arbitrator altArbitrator = DisputeAgentSelection.getRandomArbitrator(model.getArbitratorManager(), excludedArbitrators);
if (altArbitrator == null) { if (altArbitrator == null) {
errorMessageHandler.handleErrorMessage("Offer " + request.getOfferId() + " could not be signed by any arbitrator"); errorMessageHandler.handleErrorMessage("Offer " + request.getOfferId() + " could not be signed by any arbitrator");
return; return;
} }
// send request to alrernative arbitrator
log.info("Using alternative arbitrator {}", altArbitrator.getNodeAddress()); log.info("Using alternative arbitrator {}", altArbitrator.getNodeAddress());
model.getProtocol().startTimeoutTimer(); // reset timeout
sendSignOfferRequests(request, altArbitrator.getNodeAddress(), excludedArbitrators, resultHandler, errorMessageHandler); sendSignOfferRequests(request, altArbitrator.getNodeAddress(), excludedArbitrators, resultHandler, errorMessageHandler);
} }
}); });

View file

@ -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"); 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); trade.getProtocol().startTimeout(TradeProtocol.TRADE_TIMEOUT);
// save process state // save process state