mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-11-17 00:07:49 +00:00
reset timeout timer on progress creating offer
This commit is contained in:
parent
1df2ab4389
commit
c7b8571842
5 changed files with 14 additions and 2 deletions
|
@ -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,
|
||||||
|
|
|
@ -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"));
|
||||||
|
|
|
@ -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());
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue