reset timeout timer after maker sends sign offer request

This commit is contained in:
woodser 2023-11-16 10:25:12 -05:00
parent 83352ec1e3
commit 5294baf949

View File

@ -62,12 +62,13 @@ public class PlaceOfferProtocol {
public void placeOffer() {
timeoutTimer = UserThread.runAfter(() -> {
handleError(Res.get("createOffer.timeoutAtPublishing"));
}, TradeProtocol.TRADE_TIMEOUT);
startTimeoutTimer();
TaskRunner<PlaceOfferModel> taskRunner = new TaskRunner<>(model,
() -> {
// reset timer if response not yet received
if (model.getSignOfferResponse() == null) startTimeoutTimer();
},
(errorMessage) -> {
handleError(errorMessage);
@ -99,10 +100,7 @@ public class PlaceOfferProtocol {
}
// reset timer
stopTimeoutTimer();
timeoutTimer = UserThread.runAfter(() -> {
handleError(Res.get("createOffer.timeoutAtPublishing"));
}, TradeProtocol.TRADE_TIMEOUT);
startTimeoutTimer();
TaskRunner<PlaceOfferModel> taskRunner = new TaskRunner<>(model,
() -> {
@ -130,6 +128,13 @@ public class PlaceOfferProtocol {
taskRunner.run();
}
private void startTimeoutTimer() {
stopTimeoutTimer();
timeoutTimer = UserThread.runAfter(() -> {
handleError(Res.get("createOffer.timeoutAtPublishing"));
}, TradeProtocol.TRADE_TIMEOUT);
}
private void stopTimeoutTimer() {
if (timeoutTimer != null) {
timeoutTimer.stop();