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;
@Setter
private SignOfferResponse signOfferResponse;
@Setter
@Getter
protected PlaceOfferProtocol protocol;
public PlaceOfferModel(OpenOffer openOffer,
BigInteger reservedFundsForOffer,

View File

@ -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"));

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");
}
// reset protocol timeout
model.getProtocol().startTimeoutTimer();
// collect reserved key images
List<String> reservedKeyImages = new ArrayList<String>();
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) {
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);
}
});

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");
}
// extend protocol timeout
// reset protocol timeout
trade.getProtocol().startTimeout(TradeProtocol.TRADE_TIMEOUT);
// save process state