From 0cf7169587468b84519f1eca7da5053ec4aba76c Mon Sep 17 00:00:00 2001 From: sqrrm Date: Mon, 17 Feb 2020 17:50:19 +0100 Subject: [PATCH] Allow 4 refreshes per trade --- core/src/main/java/bisq/core/trade/Trade.java | 9 ++++----- .../pendingtrades/steps/seller/SellerStep2View.java | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/trade/Trade.java b/core/src/main/java/bisq/core/trade/Trade.java index e6f729e14d7..a4aab2cdebb 100644 --- a/core/src/main/java/bisq/core/trade/Trade.java +++ b/core/src/main/java/bisq/core/trade/Trade.java @@ -76,8 +76,6 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import java.time.temporal.ChronoUnit; - import java.util.Date; import java.util.HashSet; import java.util.Optional; @@ -101,8 +99,6 @@ @Slf4j public abstract class Trade implements Tradable, Model { - public static final long REFRESH_INTERVAL = ChronoUnit.DAYS.getDuration().toMillis(); - /////////////////////////////////////////////////////////////////////////////////////////// // Enums /////////////////////////////////////////////////////////////////////////////////////////// @@ -426,6 +422,8 @@ public static protobuf.Trade.TradePeriodState toProtoMessage(Trade.TradePeriodSt @Getter @Setter private long lastRefreshRequestDate; + @Getter + private long refreshInterval; /////////////////////////////////////////////////////////////////////////////////////////// // Constructor, initialization @@ -456,6 +454,7 @@ protected Trade(Offer offer, takeOfferDate = new Date().getTime(); processModel = new ProcessModel(); lastRefreshRequestDate = takeOfferDate; + refreshInterval = offer.getPaymentMethod().getMaxTradePeriod() / 5; } @@ -1063,7 +1062,7 @@ public byte[] getArbitratorBtcPubKey() { } public boolean allowedRefresh() { - var allowRefresh = new Date().getTime() > lastRefreshRequestDate + REFRESH_INTERVAL; + var allowRefresh = new Date().getTime() > lastRefreshRequestDate + getRefreshInterval(); if (!allowRefresh) { log.info("Refresh not allowed, last refresh at {}", lastRefreshRequestDate); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep2View.java index 18c6e841062..5fb71302677 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep2View.java @@ -99,8 +99,10 @@ public void deactivate() { private void activateRefreshButton() { checkNotNull(model.dataModel.getTrade(), "No trade found"); + + Trade trade = model.dataModel.getTrade(); var timeToNextRefresh = - model.dataModel.getTrade().getLastRefreshRequestDate() + Trade.REFRESH_INTERVAL - new Date().getTime(); + trade.getLastRefreshRequestDate() + trade.getRefreshInterval() - new Date().getTime(); if (timeToNextRefresh <= 0) { refreshButtonPane.setVisible(true); } else {