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